1717 PossibleDataLossError ,
1818)
1919
20- import pandas as pd
2120from pandas import (
2221 DataFrame ,
2322 HDFStore ,
3635from pandas .io import pytables
3736from pandas .io .pytables import Term
3837
38+ pytestmark = [
39+ pytest .mark .single_cpu ,
40+ ]
41+
3942
4043@pytest .mark .parametrize ("mode" , ["r" , "r+" , "a" , "w" ])
4144def test_mode (setup_path , tmp_path , mode , using_infer_string ):
@@ -88,9 +91,7 @@ def test_mode(setup_path, tmp_path, mode, using_infer_string):
8891 else :
8992 result = read_hdf (path , "df" , mode = mode )
9093 if using_infer_string :
91- df .columns = df .columns .astype (
92- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
93- )
94+ df .columns = df .columns .astype ("str" )
9495 tm .assert_frame_equal (result , df )
9596
9697
@@ -104,11 +105,10 @@ def test_default_mode(tmp_path, setup_path, using_infer_string):
104105 path = tmp_path / setup_path
105106 df .to_hdf (path , key = "df" , mode = "w" )
106107 result = read_hdf (path , "df" )
108+ expected = df .copy ()
107109 if using_infer_string :
108- df .columns = df .columns .astype (
109- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
110- )
111- tm .assert_frame_equal (result , df )
110+ expected .columns = expected .columns .astype ("str" )
111+ tm .assert_frame_equal (result , expected )
112112
113113
114114def test_reopen_handle (tmp_path , setup_path ):
@@ -184,12 +184,8 @@ def test_open_args(setup_path, using_infer_string):
184184
185185 expected = df .copy ()
186186 if using_infer_string :
187- expected .index = expected .index .astype (
188- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
189- )
190- expected .columns = expected .columns .astype (
191- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
192- )
187+ expected .index = expected .index .astype ("str" )
188+ expected .columns = expected .columns .astype ("str" )
193189
194190 tm .assert_frame_equal (store ["df" ], expected )
195191 tm .assert_frame_equal (store ["df2" ], expected )
@@ -222,12 +218,8 @@ def test_complibs_default_settings(tmp_path, setup_path, using_infer_string):
222218 result = read_hdf (tmpfile , "df" )
223219 expected = df .copy ()
224220 if using_infer_string :
225- expected .index = expected .index .astype (
226- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
227- )
228- expected .columns = expected .columns .astype (
229- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
230- )
221+ expected .index = expected .index .astype ("str" )
222+ expected .columns = expected .columns .astype ("str" )
231223 tm .assert_frame_equal (result , expected )
232224
233225 with tables .open_file (tmpfile , mode = "r" ) as h5file :
@@ -241,12 +233,8 @@ def test_complibs_default_settings(tmp_path, setup_path, using_infer_string):
241233 result = read_hdf (tmpfile , "df" )
242234 expected = df .copy ()
243235 if using_infer_string :
244- expected .index = expected .index .astype (
245- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
246- )
247- expected .columns = expected .columns .astype (
248- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
249- )
236+ expected .index = expected .index .astype ("str" )
237+ expected .columns = expected .columns .astype ("str" )
250238 tm .assert_frame_equal (result , expected )
251239
252240 with tables .open_file (tmpfile , mode = "r" ) as h5file :
@@ -260,12 +248,8 @@ def test_complibs_default_settings(tmp_path, setup_path, using_infer_string):
260248 result = read_hdf (tmpfile , "df" )
261249 expected = df .copy ()
262250 if using_infer_string :
263- expected .index = expected .index .astype (
264- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
265- )
266- expected .columns = expected .columns .astype (
267- pd .StringDtype (storage = "pyarrow" , na_value = np .nan )
268- )
251+ expected .index = expected .index .astype ("str" )
252+ expected .columns = expected .columns .astype ("str" )
269253 tm .assert_frame_equal (result , expected )
270254
271255 with tables .open_file (tmpfile , mode = "r" ) as h5file :
@@ -379,7 +363,7 @@ def test_encoding(setup_path):
379363 ],
380364)
381365@pytest .mark .parametrize ("dtype" , ["category" , object ])
382- def test_latin_encoding (tmp_path , setup_path , dtype , val , using_infer_string ):
366+ def test_latin_encoding (tmp_path , setup_path , dtype , val ):
383367 enc = "latin-1"
384368 nan_rep = ""
385369 key = "data"
0 commit comments