Skip to content

ENH: Add new date_format option to_json matching datetime.isoformat exactly #47930

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

Open
1 of 3 tasks
PMLP-novo opened this issue Aug 2, 2022 · 1 comment
Open
1 of 3 tasks
Labels
Enhancement IO JSON read_json, to_json, json_normalize

Comments

@PMLP-novo
Copy link

PMLP-novo commented Aug 2, 2022

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I wish to have the option to serialised datetimes the same way in the same way that the build in datetime.isoformat serialises them. Such that I don't produce datetimes in different formats and my tests can be writen nices.
Right now:
pandas datetime produces: "2022-08-02T15:24:54.987Z"
compared to python datetime: "2022-08-02T15:24:54.987994"

Feature Description

I wish the following test would pass

import pandas as pd
from datetime import datetime
dt = datetime.now()
df = pd.DataFrame([{"test":dt}])
assert df.to_json(date_format="python-iso", orient="records")[0]["test"] == dt.isoformat()

Alternative Solutions

the new date_format option could have other names

Additional Context

No response

@PMLP-novo PMLP-novo added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 2, 2022
@PMLP-novo
Copy link
Author

related to #36351

@jbrockmendel jbrockmendel added the IO JSON read_json, to_json, json_normalize label Nov 25, 2022
@mroeschke mroeschke removed the Needs Triage Issue that has not been reviewed by a pandas team member label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

No branches or pull requests

3 participants