-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Ensure maximum accuracy when encoding and decoding np.datetime64[ns] values #4684
Ensure maximum accuracy when encoding and decoding np.datetime64[ns] values #4684
Conversation
It probably doesn't really matter though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @spencerkclark this looks good to me.
Looks great, thanks! Do I understand this correctly - you won't have to specify |
Yup exactly -- with this PR, if nothing is specified in the |
Thanks @spencerkclark |
isort . && black . && mypy . && flake8
whats-new.rst
This PR cleans up the logic used to encode and decode times with pandas so that by default we use
int64
values in both directions for all precisions down to nanosecond. If a user specifies an encoding (or a file is read in) such thatfloat
values would be required, things still work as they did before. I do this mainly by following the approach I described here: #4045 (comment).In the process of doing this I made a few changes to
coding.times._decode_datetime_with_pandas
:decode_cf_datetime
#1414 without having to cast the input array to afloat
dtype first.Note this will change the default units that are chosen for encoding times in some instances -- previously we would never default to anything more precise than seconds -- but I think this change is for the better.
cc: @aldanor
@hmaarrfk this overlaps a little with your work in #4400, so I'm giving you credit here too (I hope you don't mind!).