Skip to content

pandas.Series does not allow adding timedeltas to series of timestamps with datetime information #10763

Closed
@ghost

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]')

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions