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

API: Series/DTIndex arithmetic with timedeltas and offsets should work the same #4134

Closed
hayd opened this issue Jul 5, 2013 · 0 comments · Fixed by #4534
Closed

API: Series/DTIndex arithmetic with timedeltas and offsets should work the same #4134

hayd opened this issue Jul 5, 2013 · 0 comments · Fixed by #4534
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves Timedelta Timedelta data type
Milestone

Comments

@hayd
Copy link
Contributor

hayd commented Jul 5, 2013

from stack: http://stackoverflow.com/questions/17491446/wrong-result-from-timedelta-operation/17492653#17492653

In [101]: rng = pd.date_range('2013', '2014')

In [102]: rng
Out[102]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-07-05 00:00:00, ..., 2014-07-05 00:00:00]
Length: 366, Freq: D, Timezone: None

In [103]: s = pd.Series(rng)

These work

In [105]: rng - pd.offsets.Hour(1)
Out[105]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-07-04 23:00:00, ..., 2014-07-04 23:00:00]
Length: 366, Freq: D, Timezone: None

In [106]: s - np.timedelta64(100000000)

but the other way around doesn't.

In [107]: rng - np.timedelta64(100000000)
NotImplementedError:

In [108]: s - pd.offsets.Hour(1)
ValueError: cannot operate on a series with out a rhs of a series/ndarray of type datetime64[ns] or a timedelta

cc #3009.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant