From 018edd88b9d378b7d3d8732d0b127214d33daf9a Mon Sep 17 00:00:00 2001 From: arw2019 Date: Sun, 11 Oct 2020 20:38:14 +0000 Subject: [PATCH] move pytables timezone aware tests from test_store.py -> test_timezone.py --- pandas/tests/io/pytables/test_store.py | 23 -------------------- pandas/tests/io/pytables/test_timezones.py | 25 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index 1e1c9e91faa4b..e9cc1e6d5b1c3 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -2189,17 +2189,6 @@ def test_calendar_roundtrip_issue(self, setup_path): result = store.select("table") tm.assert_series_equal(result, s) - def test_roundtrip_tz_aware_index(self, setup_path): - # GH 17618 - time = pd.Timestamp("2000-01-01 01:00:00", tz="US/Eastern") - df = pd.DataFrame(data=[0], index=[time]) - - with ensure_clean_store(setup_path) as store: - store.put("frame", df, format="fixed") - recons = store["frame"] - tm.assert_frame_equal(recons, df) - assert recons.index[0].value == 946706400000000000 - def test_append_with_timedelta(self, setup_path): # GH 3577 # append timedelta @@ -2554,18 +2543,6 @@ def test_store_index_name(self, setup_path): recons = store["frame"] tm.assert_frame_equal(recons, df) - def test_store_index_name_with_tz(self, setup_path): - # GH 13884 - df = pd.DataFrame({"A": [1, 2]}) - df.index = pd.DatetimeIndex([1234567890123456787, 1234567890123456788]) - df.index = df.index.tz_localize("UTC") - df.index.name = "foo" - - with ensure_clean_store(setup_path) as store: - store.put("frame", df, format="table") - recons = store["frame"] - tm.assert_frame_equal(recons, df) - @pytest.mark.parametrize("table_format", ["table", "fixed"]) def test_store_index_name_numpy_str(self, table_format, setup_path): # GH #13492 diff --git a/pandas/tests/io/pytables/test_timezones.py b/pandas/tests/io/pytables/test_timezones.py index 1c29928991cde..dc28e9543f19e 100644 --- a/pandas/tests/io/pytables/test_timezones.py +++ b/pandas/tests/io/pytables/test_timezones.py @@ -210,6 +210,31 @@ def test_append_with_timezones_pytz(setup_path): tm.assert_frame_equal(result, df) +def test_roundtrip_tz_aware_index(setup_path): + # GH 17618 + time = pd.Timestamp("2000-01-01 01:00:00", tz="US/Eastern") + df = pd.DataFrame(data=[0], index=[time]) + + with ensure_clean_store(setup_path) as store: + store.put("frame", df, format="fixed") + recons = store["frame"] + tm.assert_frame_equal(recons, df) + assert recons.index[0].value == 946706400000000000 + + +def test_store_index_name_with_tz(setup_path): + # GH 13884 + df = pd.DataFrame({"A": [1, 2]}) + df.index = pd.DatetimeIndex([1234567890123456787, 1234567890123456788]) + df.index = df.index.tz_localize("UTC") + df.index.name = "foo" + + with ensure_clean_store(setup_path) as store: + store.put("frame", df, format="table") + recons = store["frame"] + tm.assert_frame_equal(recons, df) + + def test_tseries_select_index_column(setup_path): # GH7777 # selecting a UTC datetimeindex column did