Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] 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
from datetime import datetime, timezone
# Saving and loading without timezones (works fine)
df = pd.DataFrame({
'timestamp': [
datetime(2025, 8, 14, 12, 34, 56, 0), # No microseconds
datetime(2025, 8, 14, 12, 34, 56, 1) # With microseconds
]
})
df.to_csv('test.csv', index=False)
## == test.csv == ##
# timestamp
# 2025-08-14 12:34:56.000000
# 2025-08-14 12:34:56.000001
####################
df2 = pd.read_csv("test.csv", parse_dates=["timestamp"])
print(df2.dtypes["timestamp"]) # datetime64[ns]
# Saving and loading with timezones (broken)
df = pd.DataFrame({
'timestamp': [
datetime(2025, 8, 14, 12, 34, 56, 0, tzinfo=timezone.utc), # No microseconds
datetime(2025, 8, 14, 12, 34, 56, 1, tzinfo=timezone.utc) # With microseconds
]
})
## == test.csv == ##
# timestamp
# 2025-08-14 12:34:56+00:00
# 2025-08-14 12:34:56.000001+00:00
####################
df.to_csv('test.csv', index=False)
df2 = pd.read_csv("test.csv", parse_dates=["timestamp"])
print(df2.dtypes["timestamp"]) # object
Issue Description
When saving a datetime column with timezones to a csv, pandas uses an inconsistent format across entries depending on whether the microseconds is zero or nonzero. This means that pandas then fails to parse that column when reading in the same file.
Expected Behavior
The save behavior for dates with timezones should match the behavior for dates without timezones in this case: i.e. use a consistent datetime format that includes microseconds for all rows.
Installed Versions
INSTALLED VERSIONS
------------------
commit : c888af6d0bb674932007623c0867e1fbd4bdc2c6
python : 3.13.5
python-bits : 64
OS : Darwin
OS-release : 24.3.0
Version : Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.3.1
numpy : 2.3.2
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.2
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : 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 : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None