From 10c307b4e97b137787d146e362ec6c91ac3efef2 Mon Sep 17 00:00:00 2001 From: Antriksh006 Date: Sat, 20 Dec 2025 01:32:22 +0530 Subject: [PATCH 1/4] Replace ensure_clean_store instances with temp_file --- pandas/tests/io/pytables/test_select.py | 91 ++++++++++++------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/pandas/tests/io/pytables/test_select.py b/pandas/tests/io/pytables/test_select.py index 73548ad3eb283..90b18905963fd 100644 --- a/pandas/tests/io/pytables/test_select.py +++ b/pandas/tests/io/pytables/test_select.py @@ -20,7 +20,6 @@ ) from pandas.tests.io.pytables.common import ( _maybe_remove, - ensure_clean_store, ) from pandas.io.pytables import Term @@ -28,7 +27,7 @@ pytestmark = [pytest.mark.single_cpu] -def test_select_columns_in_where(setup_path): +def test_select_columns_in_where(temp_file): # GH 6169 # recreate multi-indexes when columns is passed # in the `where` argument @@ -45,7 +44,7 @@ def test_select_columns_in_where(setup_path): columns=["A", "B", "C"], ) - with ensure_clean_store(setup_path) as store: + with HDFStore(temp_file, mode="a") as store: store.put("df", df, format="table") expected = df[["A"]] @@ -55,19 +54,19 @@ def test_select_columns_in_where(setup_path): # With a Series s = Series(np.random.default_rng(2).standard_normal(10), index=index, name="A") - with ensure_clean_store(setup_path) as store: + with HDFStore(temp_file, mode="a") as store: store.put("s", s, format="table") tm.assert_series_equal(store.select("s", where="columns=['A']"), s) -def test_select_with_dups(setup_path): +def test_select_with_dups(temp_file): # single dtypes df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=["A", "A", "B", "B"] ) df.index = date_range("20130101 9:30", periods=10, freq="min", unit="ns") - with ensure_clean_store(setup_path) as store: + with HDFStore(temp_file, mode="a") as store: store.append("df", df) result = store.select("df") @@ -98,7 +97,7 @@ def test_select_with_dups(setup_path): ) df.index = date_range("20130101 9:30", periods=10, freq="min", unit="ns") - with ensure_clean_store(setup_path) as store: + with HDFStore(temp_file, mode="a") as store: store.append("df", df) result = store.select("df") @@ -118,7 +117,7 @@ def test_select_with_dups(setup_path): tm.assert_frame_equal(result, expected, by_blocks=True) # duplicates on both index and columns - with ensure_clean_store(setup_path) as store: + with HDFStore(temp_file, mode="a") as store: store.append("df", df) store.append("df", df) @@ -128,8 +127,8 @@ def test_select_with_dups(setup_path): tm.assert_frame_equal(result, expected, by_blocks=True) -def test_select(setup_path): - with ensure_clean_store(setup_path) as store: +def test_select(temp_file): + with HDFStore(temp_file, mode="a") as store: # select with columns= df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), @@ -169,8 +168,8 @@ def test_select(setup_path): tm.assert_frame_equal(expected, result) -def test_select_dtypes(setup_path, request): - with ensure_clean_store(setup_path) as store: +def test_select_dtypes(file_path, request): + with HDFStore(file_path, mode="a") as store: # with a Timestamp data column (GH #2637) df = DataFrame( { @@ -232,7 +231,7 @@ def test_select_dtypes(setup_path, request): expected = df.reindex(index=list(df.index)[0:10], columns=["A"]) tm.assert_frame_equal(expected, result) - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path, mode="a") as store: # floats w/o NaN df = DataFrame({"cols": range(11), "values": range(11)}, dtype="float64") df["cols"] = (df["cols"] + 10).apply(str) @@ -270,7 +269,7 @@ def test_select_dtypes(setup_path, request): # test selection with comparison against numpy scalar # GH 11283 - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path, mode="a") as store: df = DataFrame( 1.1 * np.arange(120).reshape((30, 4)), columns=Index(list("ABCD")), @@ -292,8 +291,8 @@ def test_select_dtypes(setup_path, request): tm.assert_frame_equal(expected, result) -def test_select_with_many_inputs(setup_path): - with ensure_clean_store(setup_path) as store: +def test_select_with_many_inputs(file_path): + with HDFStore(file_path, mode="a") as store: df = DataFrame( { "ts": bdate_range("2012-01-01", periods=300, unit="ns"), @@ -340,9 +339,9 @@ def test_select_with_many_inputs(setup_path): assert len(result) == 100 -def test_select_iterator(tmp_path, setup_path): +def test_select_iterator(tmp_path, file_path): # single table - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -366,7 +365,7 @@ def test_select_iterator(tmp_path, setup_path): result = concat(results) tm.assert_frame_equal(result, expected) - path = tmp_path / setup_path + path = tmp_path / file_path df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), @@ -382,7 +381,7 @@ def test_select_iterator(tmp_path, setup_path): with pytest.raises(TypeError, match=msg): read_hdf(path, "df_non_table", iterator=True) - path = tmp_path / setup_path + path = tmp_path / file_path df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), @@ -400,7 +399,7 @@ def test_select_iterator(tmp_path, setup_path): # multiple - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: df1 = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -422,13 +421,13 @@ def test_select_iterator(tmp_path, setup_path): tm.assert_frame_equal(expected, result) -def test_select_iterator_complete_8014(setup_path): +def test_select_iterator_complete_8014(file_path): # GH 8014 # using iterator and where clause chunksize = 1e4 # no iterator - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -463,7 +462,7 @@ def test_select_iterator_complete_8014(setup_path): tm.assert_frame_equal(expected, result) # with iterator, full range - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -499,13 +498,13 @@ def test_select_iterator_complete_8014(setup_path): tm.assert_frame_equal(expected, result) -def test_select_iterator_non_complete_8014(setup_path): +def test_select_iterator_non_complete_8014(file_path): # GH 8014 # using iterator and where clause chunksize = 1e4 # with iterator, non complete range - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -539,7 +538,7 @@ def test_select_iterator_non_complete_8014(setup_path): tm.assert_frame_equal(rexpected, result) # with iterator, empty where - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -563,7 +562,7 @@ def test_select_iterator_many_empty_frames(setup_path): chunksize = 10_000 # with iterator, range limited to the first chunk - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -615,14 +614,14 @@ def test_select_iterator_many_empty_frames(setup_path): assert len(results) == 0 -def test_frame_select(setup_path, request): +def test_frame_select(file_path, request): df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), index=date_range("2000-01-01", periods=10, freq="B", unit="ns"), ) - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: store.put("frame", df, format="table") date = df.index[len(df) // 2] @@ -664,7 +663,7 @@ def test_frame_select(setup_path, request): # store.select('frame', [crit1, crit2]) -def test_frame_select_complex(setup_path): +def test_frame_select_complex(file_path): # select via complex criteria df = DataFrame( @@ -675,7 +674,7 @@ def test_frame_select_complex(setup_path): df["string"] = "foo" df.loc[df.index[0:4], "string"] = "bar" - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: store.put("df", df, format="table", data_columns=["string"]) # empty @@ -781,7 +780,7 @@ def test_frame_select_complex2(tmp_path): tm.assert_frame_equal(result, expected) -def test_invalid_filtering(setup_path): +def test_invalid_filtering(file_path): # can't use more than one filter (atm) df = DataFrame( @@ -790,7 +789,7 @@ def test_invalid_filtering(setup_path): index=date_range("2000-01-01", periods=10, freq="B", unit="ns"), ) - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: store.put("df", df, format="table") msg = "unable to collapse Joint Filters" @@ -803,9 +802,9 @@ def test_invalid_filtering(setup_path): store.select("df", "columns=['A','B'] & columns=['C']") -def test_string_select(setup_path): +def test_string_select(file_path): # GH 2973 - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -849,7 +848,7 @@ def test_string_select(setup_path): tm.assert_frame_equal(result, expected) -def test_select_as_multiple(setup_path): +def test_select_as_multiple(file_path): df1 = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -858,7 +857,7 @@ def test_select_as_multiple(setup_path): df2 = df1.copy().rename(columns="{}_2".format) df2["foo"] = "bar" - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: msg = "keys must be a list/tuple" # no tables stored with pytest.raises(TypeError, match=msg): @@ -924,8 +923,8 @@ def test_select_as_multiple(setup_path): ) -def test_nan_selection_bug_4858(setup_path): - with ensure_clean_store(setup_path) as store: +def test_nan_selection_bug_4858(file_path): + with HDFStore(file_path) as store: df = DataFrame({"cols": range(6), "values": range(6)}, dtype="float64") df["cols"] = (df["cols"] + 10).apply(str) df.iloc[0] = np.nan @@ -941,7 +940,7 @@ def test_nan_selection_bug_4858(setup_path): tm.assert_frame_equal(result, expected) -def test_query_with_nested_special_character(setup_path): +def test_query_with_nested_special_character(file_path): df = DataFrame( { "a": ["a", "a", "c", "b", "test & test", "c", "b", "e"], @@ -949,17 +948,17 @@ def test_query_with_nested_special_character(setup_path): } ) expected = df[df.a == "test & test"] - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: store.append("test", df, format="table", data_columns=True) result = store.select("test", 'a = "test & test"') tm.assert_frame_equal(expected, result) -def test_query_long_float_literal(setup_path): +def test_query_long_float_literal(file_path): # GH 14241 df = DataFrame({"A": [1000000000.0009, 1000000000.0011, 1000000000.0015]}) - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: store.append("test", df, format="table", data_columns=True) cutoff = 1000000000.0006 @@ -977,7 +976,7 @@ def test_query_long_float_literal(setup_path): tm.assert_frame_equal(expected, result) -def test_query_compare_column_type(setup_path): +def test_query_compare_column_type(file_path): # GH 15492 df = DataFrame( { @@ -989,7 +988,7 @@ def test_query_compare_column_type(setup_path): columns=["date", "real_date", "float", "int"], ) - with ensure_clean_store(setup_path) as store: + with HDFStore(file_path) as store: store.append("test", df, format="table", data_columns=True) ts = Timestamp("2014-01-01") # noqa: F841 From 4516eee287556382f2def192625ad066f22919e5 Mon Sep 17 00:00:00 2001 From: Antriksh006 Date: Sat, 20 Dec 2025 01:48:35 +0530 Subject: [PATCH 2/4] . --- pandas/tests/io/pytables/test_select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/pytables/test_select.py b/pandas/tests/io/pytables/test_select.py index 90b18905963fd..1b20ab979185b 100644 --- a/pandas/tests/io/pytables/test_select.py +++ b/pandas/tests/io/pytables/test_select.py @@ -555,7 +555,7 @@ def test_select_iterator_non_complete_8014(file_path): assert 0 == len(results) -def test_select_iterator_many_empty_frames(setup_path): +def test_select_iterator_many_empty_frames(file_path): # GH 8014 # using iterator and where clause can return many empty # frames. From 97486997e84ffd644cc7fa184704a56474538783 Mon Sep 17 00:00:00 2001 From: Antriksh006 Date: Sat, 20 Dec 2025 12:10:54 +0530 Subject: [PATCH 3/4] changed file_setup instances to setup_path --- pandas/tests/io/pytables/test_select.py | 53 ++++++++++++------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/pandas/tests/io/pytables/test_select.py b/pandas/tests/io/pytables/test_select.py index 73548ad3eb283..ba3856ca14955 100644 --- a/pandas/tests/io/pytables/test_select.py +++ b/pandas/tests/io/pytables/test_select.py @@ -20,7 +20,6 @@ ) from pandas.tests.io.pytables.common import ( _maybe_remove, - ensure_clean_store, ) from pandas.io.pytables import Term @@ -45,7 +44,7 @@ def test_select_columns_in_where(setup_path): columns=["A", "B", "C"], ) - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: store.put("df", df, format="table") expected = df[["A"]] @@ -55,7 +54,7 @@ def test_select_columns_in_where(setup_path): # With a Series s = Series(np.random.default_rng(2).standard_normal(10), index=index, name="A") - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: store.put("s", s, format="table") tm.assert_series_equal(store.select("s", where="columns=['A']"), s) @@ -67,7 +66,7 @@ def test_select_with_dups(setup_path): ) df.index = date_range("20130101 9:30", periods=10, freq="min", unit="ns") - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: store.append("df", df) result = store.select("df") @@ -98,7 +97,7 @@ def test_select_with_dups(setup_path): ) df.index = date_range("20130101 9:30", periods=10, freq="min", unit="ns") - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: store.append("df", df) result = store.select("df") @@ -118,7 +117,7 @@ def test_select_with_dups(setup_path): tm.assert_frame_equal(result, expected, by_blocks=True) # duplicates on both index and columns - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: store.append("df", df) store.append("df", df) @@ -129,7 +128,7 @@ def test_select_with_dups(setup_path): def test_select(setup_path): - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: # select with columns= df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), @@ -170,7 +169,7 @@ def test_select(setup_path): def test_select_dtypes(setup_path, request): - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: # with a Timestamp data column (GH #2637) df = DataFrame( { @@ -232,7 +231,7 @@ def test_select_dtypes(setup_path, request): expected = df.reindex(index=list(df.index)[0:10], columns=["A"]) tm.assert_frame_equal(expected, result) - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: # floats w/o NaN df = DataFrame({"cols": range(11), "values": range(11)}, dtype="float64") df["cols"] = (df["cols"] + 10).apply(str) @@ -270,7 +269,7 @@ def test_select_dtypes(setup_path, request): # test selection with comparison against numpy scalar # GH 11283 - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: df = DataFrame( 1.1 * np.arange(120).reshape((30, 4)), columns=Index(list("ABCD")), @@ -293,7 +292,7 @@ def test_select_dtypes(setup_path, request): def test_select_with_many_inputs(setup_path): - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path, mode="a") as store: df = DataFrame( { "ts": bdate_range("2012-01-01", periods=300, unit="ns"), @@ -342,7 +341,7 @@ def test_select_with_many_inputs(setup_path): def test_select_iterator(tmp_path, setup_path): # single table - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -400,7 +399,7 @@ def test_select_iterator(tmp_path, setup_path): # multiple - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: df1 = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -428,7 +427,7 @@ def test_select_iterator_complete_8014(setup_path): chunksize = 1e4 # no iterator - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -463,7 +462,7 @@ def test_select_iterator_complete_8014(setup_path): tm.assert_frame_equal(expected, result) # with iterator, full range - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -505,7 +504,7 @@ def test_select_iterator_non_complete_8014(setup_path): chunksize = 1e4 # with iterator, non complete range - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -539,7 +538,7 @@ def test_select_iterator_non_complete_8014(setup_path): tm.assert_frame_equal(rexpected, result) # with iterator, empty where - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -563,7 +562,7 @@ def test_select_iterator_many_empty_frames(setup_path): chunksize = 10_000 # with iterator, range limited to the first chunk - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: expected = DataFrame( np.random.default_rng(2).standard_normal((100064, 4)), columns=Index(list("ABCD")), @@ -622,7 +621,7 @@ def test_frame_select(setup_path, request): index=date_range("2000-01-01", periods=10, freq="B", unit="ns"), ) - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: store.put("frame", df, format="table") date = df.index[len(df) // 2] @@ -675,7 +674,7 @@ def test_frame_select_complex(setup_path): df["string"] = "foo" df.loc[df.index[0:4], "string"] = "bar" - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: store.put("df", df, format="table", data_columns=["string"]) # empty @@ -790,7 +789,7 @@ def test_invalid_filtering(setup_path): index=date_range("2000-01-01", periods=10, freq="B", unit="ns"), ) - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: store.put("df", df, format="table") msg = "unable to collapse Joint Filters" @@ -805,7 +804,7 @@ def test_invalid_filtering(setup_path): def test_string_select(setup_path): # GH 2973 - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=Index(list("ABCD")), @@ -858,7 +857,7 @@ def test_select_as_multiple(setup_path): df2 = df1.copy().rename(columns="{}_2".format) df2["foo"] = "bar" - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: msg = "keys must be a list/tuple" # no tables stored with pytest.raises(TypeError, match=msg): @@ -925,7 +924,7 @@ def test_select_as_multiple(setup_path): def test_nan_selection_bug_4858(setup_path): - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: df = DataFrame({"cols": range(6), "values": range(6)}, dtype="float64") df["cols"] = (df["cols"] + 10).apply(str) df.iloc[0] = np.nan @@ -949,7 +948,7 @@ def test_query_with_nested_special_character(setup_path): } ) expected = df[df.a == "test & test"] - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: store.append("test", df, format="table", data_columns=True) result = store.select("test", 'a = "test & test"') tm.assert_frame_equal(expected, result) @@ -959,7 +958,7 @@ def test_query_long_float_literal(setup_path): # GH 14241 df = DataFrame({"A": [1000000000.0009, 1000000000.0011, 1000000000.0015]}) - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: store.append("test", df, format="table", data_columns=True) cutoff = 1000000000.0006 @@ -989,7 +988,7 @@ def test_query_compare_column_type(setup_path): columns=["date", "real_date", "float", "int"], ) - with ensure_clean_store(setup_path) as store: + with HDFStore(setup_path) as store: store.append("test", df, format="table", data_columns=True) ts = Timestamp("2014-01-01") # noqa: F841 From c61a1c72ee17eec088048258be90a32b77af5e34 Mon Sep 17 00:00:00 2001 From: Antriksh006 Date: Mon, 22 Dec 2025 22:56:41 +0530 Subject: [PATCH 4/4] slight change --- pandas/tests/io/pytables/test_select.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pandas/tests/io/pytables/test_select.py b/pandas/tests/io/pytables/test_select.py index ba3856ca14955..a416c39c05e04 100644 --- a/pandas/tests/io/pytables/test_select.py +++ b/pandas/tests/io/pytables/test_select.py @@ -44,7 +44,7 @@ def test_select_columns_in_where(setup_path): columns=["A", "B", "C"], ) - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: store.put("df", df, format="table") expected = df[["A"]] @@ -54,7 +54,7 @@ def test_select_columns_in_where(setup_path): # With a Series s = Series(np.random.default_rng(2).standard_normal(10), index=index, name="A") - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: store.put("s", s, format="table") tm.assert_series_equal(store.select("s", where="columns=['A']"), s) @@ -66,7 +66,7 @@ def test_select_with_dups(setup_path): ) df.index = date_range("20130101 9:30", periods=10, freq="min", unit="ns") - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: store.append("df", df) result = store.select("df") @@ -97,7 +97,7 @@ def test_select_with_dups(setup_path): ) df.index = date_range("20130101 9:30", periods=10, freq="min", unit="ns") - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: store.append("df", df) result = store.select("df") @@ -117,7 +117,7 @@ def test_select_with_dups(setup_path): tm.assert_frame_equal(result, expected, by_blocks=True) # duplicates on both index and columns - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: store.append("df", df) store.append("df", df) @@ -128,7 +128,7 @@ def test_select_with_dups(setup_path): def test_select(setup_path): - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: # select with columns= df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), @@ -169,7 +169,7 @@ def test_select(setup_path): def test_select_dtypes(setup_path, request): - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: # with a Timestamp data column (GH #2637) df = DataFrame( { @@ -231,7 +231,7 @@ def test_select_dtypes(setup_path, request): expected = df.reindex(index=list(df.index)[0:10], columns=["A"]) tm.assert_frame_equal(expected, result) - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: # floats w/o NaN df = DataFrame({"cols": range(11), "values": range(11)}, dtype="float64") df["cols"] = (df["cols"] + 10).apply(str) @@ -269,7 +269,7 @@ def test_select_dtypes(setup_path, request): # test selection with comparison against numpy scalar # GH 11283 - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: df = DataFrame( 1.1 * np.arange(120).reshape((30, 4)), columns=Index(list("ABCD")), @@ -292,7 +292,7 @@ def test_select_dtypes(setup_path, request): def test_select_with_many_inputs(setup_path): - with HDFStore(setup_path, mode="a") as store: + with HDFStore(setup_path, mode="w") as store: df = DataFrame( { "ts": bdate_range("2012-01-01", periods=300, unit="ns"),