-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DEPR: 'epoch' date format in to_json #57987
DEPR: 'epoch' date format in to_json #57987
Conversation
Thanks for taking a look at this! |
@@ -2530,6 +2535,14 @@ def to_json( | |||
date_format = "iso" | |||
elif date_format is None: |
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.
I think need to warn for anything that is not currently iso
, including when date_format is None (although the message will be different)
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.
Can you also add a warning for the date_format=None
case that previously defaulted to "epoch"; this should in the future default to "iso"
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.
Most of the to_json
use cases don't involve dates and wouldn't be affected by the date_format
value, throwing a warning in these cases might be unnecessary, essentially they will need to pass date_format='iso'
for no reason to silence this warning, are you sure we should do this?
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.
Sorry to be more specific we need to warn when date_format=None
and we actually serialize timestamp types. I agree no point in warning if a DataFrame has no timestamp type, but if users are relying on the default epoch behavior they need to be warned of the change
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.
@WillAyd curious how would users get the old behavior? It would be good to add that in the warning message
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.
The old behavior as in just an integer? I think the problem with that is it was an implementation detail of pandas spilling out into the JSON serializer. Historically our timestamps were exclusively nanoseconds since the Unix epoch, but with all the work @jbrockmendel has been doing that is no longer true (and _usually not true).
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.
The old behavior as in just an integer?
Yeah. Just checking if we can still offer a suggestion for a migration path if they want to keep the old behavior
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.
I don't think so. Especially with our auto-inferencing of resolutions I don't see how it would be usable at all roundtripping through JSON
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.
OK sounds good
@@ -2530,6 +2535,14 @@ def to_json( | |||
date_format = "iso" | |||
elif date_format is None: |
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.
Can you also add a warning for the date_format=None
case that previously defaulted to "epoch"; this should in the future default to "iso"
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.
Generally looks nice. Can you also add a test that is parametrized by DataFrames that may or may not have datetimelike values? In the case the DataFrame does not we want to assert no warning is raised
This comment has been minimized.
This comment has been minimized.
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.
Looking good
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.
@mroeschke any thoughts?
Thanks @Aloqeely |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.