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

Comments

@kernc
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Sep 14, 2018

xref #13829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.