Skip to content

TST: Add test for retaining dtype of datetime columns in DataFrame.to_hdf #61112

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

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pandas/tests/io/pytables/test_retain_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,16 @@ def test_retain_index_attributes2(tmp_path, setup_path):
df2.to_hdf(path, key="data", append=True)

assert read_hdf(path, "data").index.name is None


def test_retain_datetime_attribute(tmp_path, setup_path):
path = tmp_path / setup_path
ser = Series(
["2024-08-26 15:13:14", "2024-08-26 15:14:14"],
dtype="datetime64[us, UTC]",
)
dataframe = DataFrame(ser)
dataframe.to_hdf(path, key="Annotations", mode="w")

recovered_dataframe = read_hdf(path, key="Annotations")
tm.assert_frame_equal(dataframe, recovered_dataframe)
Loading