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: Setting timedelta column by index causes it to loss precision #23511

Closed
icexelloss opened this issue Nov 5, 2018 · 0 comments · Fixed by #23462
Closed

BUG: Setting timedelta column by index causes it to loss precision #23511

icexelloss opened this issue Nov 5, 2018 · 0 comments · Fixed by #23462
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type
Milestone

Comments

@icexelloss
Copy link
Contributor

Code Sample, a copy-pastable example if possible

dt1 = pd.Timedelta(0)
dt2 = pd.Timedelta(28767471428571405)
df = pd.DataFrame({'dt': pd.Series([dt1, dt2])})
df_copy = df.copy()
s = pd.Series([dt1])

expected = df['dt'].iloc[1].value
df.loc[[True, False]] = s
result = df['dt'].iloc[1].value

print(result)
#28767471428571404

Problem description

Setting a timedelta column by index causes it to be casted to double and back. Therefore, it will loss precision.

Expected Output

28767471428571405

Output of pd.show_versions()

0.23.4

[paste the output of pd.show_versions() here below this line]

@icexelloss icexelloss changed the title BUG: Setting timedelta column causes it to loss precision BUG: Setting timedelta column by index causes it to loss precision Nov 5, 2018
@gfyoung gfyoung added Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Nov 5, 2018
@jreback jreback added this to the 0.24.0 milestone Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants