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 have a Dataset with two coordinates, event_date and day_offset. event_date is a datetime64[ns], while day_offset is an integer. How can I get the date shifted by the number of business days in the offset?
I tried:
xds["event_date"] +xds["day_offset"] # offset gets cast to nanosecondsxds["event_date"] +xds["day_offset"].astype(pd.offsets.BusinessDay) # numpy.core._exceptions._UFuncBinaryResolutionError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('O')xds["event_date"] + (xds["day_offset"] *pd.offsets.BusinessDay()) # same as abovexds["event_date"] +pd.Series(xds["day_offset"] *pd.offsets.BusinessDay()) # sizes mismatchxds["event_date"] +pd.to_timedelta(xds["day_offset"]).astype(pd.offsets.BusinessDay) # TypeError: dtype '<class 'BusinessDay'>' not understood
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a Dataset with two coordinates,
event_date
andday_offset
.event_date
is adatetime64[ns]
, whileday_offset
is an integer. How can I get the date shifted by the number of business days in the offset?I tried:
Is there a way to do this?
Beta Was this translation helpful? Give feedback.
All reactions