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

Comments

Projects
None yet
3 participants
@icexelloss
Copy link
Contributor

commented Nov 5, 2018

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

@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
You can’t perform that action at this time.