BUG: dataframe.to_hdf function incompatible with timestamps of format "datetime64[us, UTC]" #60353
Open
2 of 3 tasks
Labels
Bug
IO HDF5
read_hdf, HDFStore
Needs Tests
Unit test(s) needed to prevent regressions
Timezones
Timezone data dtype
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
Issue Description
Dumping a dataframe with a column of datetime64[us, UTC] datetype to an HDF file seems to write datetime[ns, UTC] into the file. When recovering the data from the HDF file it seems that the dates are wrong, which is probably caused by an erroneous interpretation of the values as datetime[ns, UTC].
Expected Behavior
datetime64[us, UTC] values which have been written from a dataframe into an HDF file using the to_hdf function should be recoverable using the pd.read_hdf function.
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.10.12
python-bits : 64
OS : Linux
OS-release : 5.15.0-118-generic
Version : #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 1.26.4
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.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 : 2024.5.0
fsspec : 2024.9.0
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : 5.3.0
matplotlib : 3.7.3
numba : None
numexpr : 2.10.1
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 17.0.0
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.1
sqlalchemy : None
tables : 3.10.1
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: