I am trying to calculate the days between two dates:
First Date:
date = datetime.datetime.today() # {datetime} 2018-09-17 14:42:06.506541
Second date, extracted from a data frame:
date2 = data_audit.loc[(data_audit.Audit == audit), 'Erledigungsdatum'].values[0]
# {datetime64} 2018-07-23T00:00:00.000000000
The error:
ufunc subtract cannot use operands with types dtype('O') and dtype('M8[ns]')
My next try was:
date = np.datetime64(datetime.datetime.now()) # {datetime64} 2018-09-17T14:48:16.599541
Which resulted in the following error (I pass the date as a parameter in a function):
ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
How should I approach this problem? The second one seems more logical to me, but I don't understand why I cant pass a simple date to a function.
Let's try such approach
And you can apply
df.some_col_with_difference.astype('timedelta64[D]')
to whole column in dataframe as well