Skip to content
Advertisement

Tag: python-datetime

How to unittest a datetime function

file.py test.py I get an Error: TypeError: ‘>’ not supported between instances of ‘MagicMock’ and ‘int’ Is there anyway to test this function? Probably the problem is with this part of the last line: (utc_date – namespace_created_date).days Answer I could reproduce and fix. Here is a working unittest file (assuming file.py is accessible): If I use date_now.datetime.utcnow.date.return_value = datetime.datetime(2022,1,1) I

Convert ’01-Feb-15′ to Python date 01/02/2015 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 11 months ago. Improve this question

Pandas: Unable to merge on two date columns

I have two dataframes that look like: df1: df2: Both date columns have been made using the pd.to_datetime() method, and they both supposedly have <M8[ns] data types when using df1.Date.dtype and df2.Date.dtype. However when trying to merge the dataframes with pd.merge(df,hpi,how=”left”,on=”Date”) I get the error: ValueError: You are trying to merge on object and datetime64[ns] columns. If you wish to

Advertisement