pandas.Series does not allow adding timedeltas to series of timestamps with datetime information · Issue #10763 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
xref #10477
It is possible with numpy, but not with pandas:
import numpy as np
import pandas as pd
ts1 = pd.Timestamp('2015-07-01 10:00:00').tz_localize('Europe/London')
ts2 = pd.Timestamp('2015-07-01 11:00:00').tz_localize('Europe/London')
dt = ts2 - ts1
x = np.array([ts1, ts2])
print(x)
dx = np.array([dt, dt])
print(x + dx)
s = pd.Series([ts1, ts2])
print(s)
ds = pd.Series([dt, dt])
print(s + ds)
s + ds
throws an error ufunc add cannot use operands with types dtype('O') and dtype('<m8[ns]')