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

BUG/API: timedelta64 series should operate directly with np.timedelta64/pd.offsets #4532

Closed
jreback opened this issue Aug 10, 2013 · 0 comments · Fixed by #4534
Closed

BUG/API: timedelta64 series should operate directly with np.timedelta64/pd.offsets #4532

jreback opened this issue Aug 10, 2013 · 0 comments · Fixed by #4534
Labels
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Aug 10, 2013

Related #4134 and:

http://stackoverflow.com/questions/18159675/python-pandas-change-duplicate-timestamp-to-unique/18162121#18162121

In [81]: df = DataFrame(dict(time = [Timestamp('20130101 9:01'),Timestamp('20130101 9:02')]))

This is buggy

In [82]: df.time + np.timedelta64(1,'ms')
Out[82]: 
0   2013-01-01 09:01:00.000000001
1   2013-01-01 09:02:00.000000001
Name: time, dtype: datetime64[ns]

In [84]: df.time + np.timedelta64(1,'s')
Out[84]: 
0   2013-01-01 09:01:00.000000001
1   2013-01-01 09:02:00.000000001
Name: time, dtype: datetime64[ns]

Doesn't work

In [83]: df.time + pd.offsets.Milli(5)
ValueError: cannot operate on a series with out a rhs of a series/ndarray of type datetime64[ns] or a timedelta

But this is ok

In [86]: df.time.apply(lambda x: x + pd.offsets.Milli(5))
Out[86]: 
0   2013-01-01 09:01:00.005000
1   2013-01-01 09:02:00.005000
Name: time, dtype: datetime64[ns]

This is ok

In [85]: df.time + timedelta(seconds=1)
Out[85]: 
0   2013-01-01 09:01:01
1   2013-01-01 09:02:01
Name: time, dtype: datetime64[ns]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant