Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Aug 7, 2015 · 4 comments · Fixed by #10477
Labels
Datetime Datetime data dtype Timezones Timezone data dtype
Milestone

Comments

@ghost
Copy link

ghost commented Aug 7, 2015

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

@jreback
Copy link
Contributor

jreback commented Aug 7, 2015

pls pd.show_versions()

@jreback
Copy link
Contributor

jreback commented Aug 7, 2015

this by definition won't work because tzs are not a real dtype (coming soon though)

and FYI numpy looks like it works but is actually do the wrong thing - it silently coerces to UTC

@ghost
Copy link
Author

ghost commented Aug 7, 2015

INSTALLED VERSIONS

commit: None
python: 2.7.3.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-220.4.2.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.15.2
nose: 1.3.0
Cython: 0.21.1
numpy: 1.9.1
scipy: 0.15.1
statsmodels: 0.5.0.dev-Unknown
IPython: 0.13.1
sphinx: 1.1.3
patsy: 0.2.1
dateutil: 2.1
pytz: 2015.4
bottleneck: None
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.2.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: 0.8
apiclient: None
rpy2: None
sqlalchemy: 0.8.0
pymysql: None
psycopg2: None

@ghost
Copy link
Author

ghost commented Aug 7, 2015

So the only option is to do it row-by-row?

@jreback jreback added Datetime Datetime data dtype Timezones Timezone data dtype labels Aug 7, 2015
@jreback jreback added this to the 0.17.0 milestone Aug 7, 2015
jreback added a commit to jreback/pandas that referenced this issue Aug 14, 2015
fix scalar comparisons vs None generally

fix NaT formattting in Series

TST: skip postgresql test with tz's

update for msgpack

Conflicts:
	pandas/core/base.py
	pandas/core/categorical.py
	pandas/core/format.py
	pandas/tests/test_base.py
	pandas/util/testing.py

full interop for tz-aware Series & timedeltas pandas-dev#10763
jreback added a commit to jreback/pandas that referenced this issue Sep 5, 2015
fix scalar comparisons vs None generally

fix NaT formattting in Series

TST: skip postgresql test with tz's

update for msgpack

Conflicts:
	pandas/core/base.py
	pandas/core/categorical.py
	pandas/core/format.py
	pandas/tests/test_base.py
	pandas/util/testing.py

full interop for tz-aware Series & timedeltas pandas-dev#10763
nickeubank pushed a commit to nickeubank/pandas that referenced this issue Sep 29, 2015
fix scalar comparisons vs None generally

fix NaT formattting in Series

TST: skip postgresql test with tz's

update for msgpack

Conflicts:
	pandas/core/base.py
	pandas/core/categorical.py
	pandas/core/format.py
	pandas/tests/test_base.py
	pandas/util/testing.py

full interop for tz-aware Series & timedeltas pandas-dev#10763
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant