17
17
PossibleDataLossError ,
18
18
)
19
19
20
- import pandas as pd
21
20
from pandas import (
22
21
DataFrame ,
23
22
HDFStore ,
36
35
from pandas .io import pytables
37
36
from pandas .io .pytables import Term
38
37
38
+ pytestmark = [
39
+ pytest .mark .single_cpu ,
40
+ ]
41
+
39
42
40
43
@pytest .mark .parametrize ("mode" , ["r" , "r+" , "a" , "w" ])
41
44
def 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):
88
91
else :
89
92
result = read_hdf (path , "df" , mode = mode )
90
93
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" )
94
95
tm .assert_frame_equal (result , df )
95
96
96
97
@@ -104,11 +105,10 @@ def test_default_mode(tmp_path, setup_path, using_infer_string):
104
105
path = tmp_path / setup_path
105
106
df .to_hdf (path , key = "df" , mode = "w" )
106
107
result = read_hdf (path , "df" )
108
+ expected = df .copy ()
107
109
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 )
112
112
113
113
114
114
def test_reopen_handle (tmp_path , setup_path ):
@@ -184,12 +184,8 @@ def test_open_args(setup_path, using_infer_string):
184
184
185
185
expected = df .copy ()
186
186
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" )
193
189
194
190
tm .assert_frame_equal (store ["df" ], expected )
195
191
tm .assert_frame_equal (store ["df2" ], expected )
@@ -222,12 +218,8 @@ def test_complibs_default_settings(tmp_path, setup_path, using_infer_string):
222
218
result = read_hdf (tmpfile , "df" )
223
219
expected = df .copy ()
224
220
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" )
231
223
tm .assert_frame_equal (result , expected )
232
224
233
225
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):
241
233
result = read_hdf (tmpfile , "df" )
242
234
expected = df .copy ()
243
235
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" )
250
238
tm .assert_frame_equal (result , expected )
251
239
252
240
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):
260
248
result = read_hdf (tmpfile , "df" )
261
249
expected = df .copy ()
262
250
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" )
269
253
tm .assert_frame_equal (result , expected )
270
254
271
255
with tables .open_file (tmpfile , mode = "r" ) as h5file :
@@ -379,7 +363,7 @@ def test_encoding(setup_path):
379
363
],
380
364
)
381
365
@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 ):
383
367
enc = "latin-1"
384
368
nan_rep = ""
385
369
key = "data"
0 commit comments