-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Rounding errors with Timestamps and .last()
#19526
Comments
Can you reproduce without the groupby step? |
I can't repro without groupby. I did a little more experimentation, and it appears that the set of aggregation functions that have the issue are exactly these ( |
this should not be going thru a float round trip which is the symptom you are seeing |
Thanks for the hint @jreback . The offending block seems to be here where the integer result is getting cast as float. The coercion back to a datetime happens in here, and from what I can tell, that "does the right thing" with This is my first look at pandas internals, but if the fix is likely to be just ripping out those lines and adding a test, I can probably manage to put a PR together. |
it’s not likely to be ‘ripping it out’ but pls have a look |
closes pandas-dev#19526 Author: Jason Bandlow <[email protected]> Closes pandas-dev#19530 from jbandlow/timestamp_float_conversion and squashes the following commits: 2fb23d6 [Jason Bandlow] merge af37225 [Jason Bandlow] BUG: Fix ts precision issue with groupby and NaT (pandas-dev#19526)
Code Sample, a copy-pastable example if possible
Problem description
The value of the Timestamp in the output is not equal to the value in the input.
Expected Output
The issue is a bit subtle. Here are three related examples, all of which do work as expected:
I haven't been able to repro with
.nth(-1)
in place oflast()
:I haven't been able to repro if
NaT
is not present:I haven't been able to repro for times which are integer seconds:
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: