You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting TypeError: cannot subtract DatetimeArray from ndarray.
Doing the subtraction in the opposite direction (series - dataframe) gives UFuncTypeError: ufunc 'subtract' cannot use operands with types dtype('<M8[ns]') and dtype('float64').
sfc-gh-mvashishtha
changed the title
BUG: subtracting datetime series from datetime dataframe raises TypeError: cannot subtract DatetimeArray from ndarray
BUG: subtracting datetime series from datetime dataframe, or datetime dataframe from datetime series, raises TypeError or UFuncTypeError
Aug 16, 2024
I also found that timestamp + timedelta and timestamp - timedelta raise a similar error, ufunc 'add' cannot use operands with types dtype('<m8[ns]') and dtype('float64')
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I'm getting
TypeError: cannot subtract DatetimeArray from ndarray
.Doing the subtraction in the opposite direction (series - dataframe) gives
UFuncTypeError: ufunc 'subtract' cannot use operands with types dtype('<M8[ns]') and dtype('float64')
.I found a related issue #31623.
Expected Behavior
This subtraction should work the way it would for integers:
so for datetimes we should align the series on axis 1 and broadcast it to each row to get an output of
Installed Versions
The text was updated successfully, but these errors were encountered: