Skip to content

Index * Series returns Index #19042

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

Closed
jbrockmendel opened this issue Jan 3, 2018 · 0 comments · Fixed by #19253
Closed

Index * Series returns Index #19042

jbrockmendel opened this issue Jan 3, 2018 · 0 comments · Fixed by #19253
Labels
Bug Datetime Datetime data dtype Timedelta Timedelta data type
Milestone

Comments

@jbrockmendel
Copy link
Member

Opening mainly so I have something to reference in the upcoming PR.

tdi = pd.TimedeltaIndex(['0days', '1day', '2days', '3days', '4days'])
ser = Series([0, 1, 2, 3, 4], dtype=np.int64)
expected = Series(['0days', '1day', '4days', '9days', '16days'],
                          dtype='timedelta64[ns]')

result = tdi * ser
tm.assert_series_equal(result, expected)   # --> fails

>>> result
TimedeltaIndex(['0 days', '1 days', '4 days', '9 days', '16 days'], dtype='timedelta64[ns]', freq=None)

Same for division:

tdi = pd.TimedeltaIndex(['0days', '1day', '2days', '3days', '4days'])
ser = Series([1.5, 3, 4.5, 6, 7.5], dtype=np.float64)
expected = Series([tdi[n] / ser[n] for n in range(len(ser))], dtype='timedelta64[ns]')

result = tdi / ser
>>> result
TimedeltaIndex(['00:00:00', '08:00:00', '10:40:00', '12:00:00', '12:48:00'], dtype='timedelta64[ns]', freq=None)
@gfyoung gfyoung added Bug Timedelta Timedelta data type Datetime Datetime data dtype labels Jan 3, 2018
@jreback jreback added this to the 0.23.0 milestone Jan 3, 2018
@jbrockmendel jbrockmendel changed the title TimedeltaIndex * Series returns TimedeltaIndex Index * Series returns Index Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants