-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Error serializing dataframes with timestamps #599
Milestone
Comments
Thanks for reporting this! I'll need to think about it a little bit more, but at a glance the approach you propose would be a better solution than what is currently implemented. A PR would indeed be welcome! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discovered "error serializing datetime" (or timestamps or others), described below, when serializing a complex class with several datetime and other parameters, and several dataframes. Identified that the issue seems to be in how pandas df's are (de)serialized - the "to_dict" function is called (see here) instead of panda's own json functions... in a df with timestamps those are simply dumped out in the resulting dict and that is attempted to be serialized, which fails as the timestamps aren't serializable without handling.
I found that by monkey patching the functions to use pandas own to_json/read_json functions I'm able to get the desired functionality. Also, by using the "table" orient option we get the schema in the output, allowing better serde roundtrip.
If the code below looks OK I'll be happy to submit a PR to add
Versions:
pandas: 1.4.0
json: 2.0.9
param: 1.12.0
python 3.10
osx
Description of expected behavior and the observed behavior:
Serialize and deserialize pandas dataframes with timestamps
Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
Example fix:
output:
The text was updated successfully, but these errors were encountered: