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

Closed
katastrofa999 opened this Issue Aug 7, 2015 · 4 comments

Comments

Projects
None yet
2 participants

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

Contributor

jreback commented Aug 7, 2015

pls pd.show_versions()

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

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

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

jreback added this to the 0.17.0 milestone Aug 7, 2015

jreback referenced this issue Aug 7, 2015

Merged

API: add DatetimeBlockTZ #8260 #10477

5 of 5 tasks complete

@jreback jreback added a commit to jreback/pandas that referenced this issue Aug 14, 2015

@jreback jreback API: add DatetimeBlockTZ #8260
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 #10763
6beba0d

@jreback jreback added a commit to jreback/pandas that referenced this issue Sep 5, 2015

@jreback jreback API: add DatetimeBlockTZ #8260
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 #10763
27b7b1e

jreback closed this in #10477 Sep 5, 2015

@nickeubank nickeubank added a commit to nickeubank/pandas that referenced this issue Sep 29, 2015

@jreback @nickeubank jreback + nickeubank API: add DatetimeBlockTZ #8260
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 #10763
1cbdcb5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment