Skip to content

BUG: Inconsistent date time handling with serialized data #66615

Description

@nanthony007

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

# read a data frame from an excel that contains year formatted column
# example: "DOD" with a format like "1/1/2015"
df1 = pd.read_excel("<link>")

# write to json lines
df.to_json("out.json", orient="records", lines=True)

# read from json lines
df2 = pd.read_json("out.json", lines=True, orient="records", typ="frame")

# at this point, the "DOD" column in df2 has been corrupted

# can be remedied with:
df2["DOD"] = pd.to_datetime(df2["DOD"], unit="ms")

Issue Description

There is inconsistency in pandas I/O regarding serialization to json.

When pandas reads in a file from a source it is sometimes smart enough to infer the date time columns datatype. This is great. However, when that data frame is written to json lines file, it serializes those date times into ISO timestamps. This is not a problem in and of itself. The issue arises when you then try to read that new file. For some reason, the ISO timestamps become corrupted. While the re-read data correctly identifies it as a date time column, all of the data reflects timestamps in 1970. This is extremely confusing as I would've expected pandas' I/O to be compatible when the writer and reader both used the same file format (json) and the default options.

While the above code sample shows a remedy, it is extremely confusing because the column does get parsed as a date time type. If it were, for example, simply parsed as a string, I would know to parse it myself.

This is my first issue so I hope I successfully explained the problem. If this is intended behavior that is fine I was looking for either: A) an explanation of why this occurs, or B) to provide a bug report.

If this part of the code is written in Python I would also be willing to attempt to tackle any changes needed but would need some guidance as a first time contributor.

Thank you for your time and the great work you do! :)

Expected Behavior

I would expect the serialization to match. So I would expect the current behavior where it parses the date time field type. However it parses the incorrect date time and that is the issue.

Installed Versions

Details

INSTALLED VERSIONS

commit : e68db09
python : 3.14.6
python-bits : 64
OS : Darwin
OS-release : 25.5.0
Version : Darwin Kernel Version 25.5.0: Tue Jun 9 22:18:58 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.0.5
numpy : 2.5.1
dateutil : 2.9.0.post0
pip : None
Cython : None
sphinx : None
IPython : 9.16.1
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
psycopg2 : None
pymysql : None
pyarrow : None
pyiceberg : None
pyreadstat : None
pytest : None
python-calamine : None
pytz : None
pyxlsb : 1.0.10
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.2
xlsxwriter : 3.2.9
zstandard : None
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions