Reputation: 840
I'm kind of new to python, today I was trying to do some operations in a financial DataFrame (first column of YYYY-MM-DD and second one of values). When I tried to apply a simple pct_change() operation, it gave me this error:
TypeError: ufunc true_divide cannot use operands with types
dtype('<M8[ns]') and dtype('<M8[ns]')
What is this error exactly caused by? And how can I work around it? Because I couldn't really find many explanations online. Thanks a lot in advance!
Upvotes: 0
Views: 5235
Reputation: 53099
dtype('<M8[ns]')
is one of the numpy
datetime64
dtypes. So it looks like you are trying do your precentage change calculation on the date column which unsuprisingly doesn't work.
The solution would be to select the value column. (I can't be more specific since you are not providing the necessary details.)
Upvotes: 2