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

Timedelta interpreted as int upon first insertion into Series #22717

Closed
kernc opened this issue Sep 14, 2018 · 1 comment · Fixed by #27303
Closed

Timedelta interpreted as int upon first insertion into Series #22717

kernc opened this issue Sep 14, 2018 · 1 comment · Fixed by #27303
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Timedelta Timedelta data type
Milestone

Comments

@kernc
Copy link
Contributor

kernc commented Sep 14, 2018

Code Sample, a copy-pastable example if possible

>>> s = pd.Series(['x'])
>>> s['td'] = pd.Timedelta('9 days')
>>> s
0                   x
td    777600000000000
dtype: object

# However, *if the key already exists*, it works as expected:
>>> s['td_2'] = 0
>>> s['td_2'] = pd.Timedelta('9 days')
>>> s
0                    x
td     777600000000000
td_2   9 days 00:00:00
dtype: object

Problem description

Timedeltas should remain Timedeltas when inserted into object Series, particularly because they are nice to work with. 😅

Expected Output

>>> s = pd.Series(['x'])
>>> s['td'] = pd.Timedelta('9 days')
>>> s
0                    x
td     9 days 00:00:00
dtype: object

Output of pd.show_versions()

pandas 0.23.3

@mroeschke
Copy link
Member

xref #13829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants