2525 ensure_clean_store ,
2626)
2727
28- pytestmark = [
29- pytest .mark .single_cpu ,
30- pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False ),
31- ]
28+ pytestmark = [pytest .mark .single_cpu ]
3229
3330tables = pytest .importorskip ("tables" )
3431
@@ -40,7 +37,7 @@ def test_append(setup_path):
4037 # tables.NaturalNameWarning):
4138 df = DataFrame (
4239 np .random .default_rng (2 ).standard_normal ((20 , 4 )),
43- columns = Index (list ("ABCD" ), dtype = object ),
40+ columns = Index (list ("ABCD" )),
4441 index = date_range ("2000-01-01" , periods = 20 , freq = "B" ),
4542 )
4643 _maybe_remove (store , "df1" )
@@ -203,7 +200,7 @@ def test_append_some_nans(setup_path):
203200 tm .assert_frame_equal (store ["df3" ], df3 , check_index_type = True )
204201
205202
206- def test_append_all_nans (setup_path ):
203+ def test_append_all_nans (setup_path , using_infer_string ):
207204 with ensure_clean_store (setup_path ) as store :
208205 df = DataFrame (
209206 {
@@ -255,7 +252,13 @@ def test_append_all_nans(setup_path):
255252 _maybe_remove (store , "df" )
256253 store .append ("df" , df [:10 ], dropna = True )
257254 store .append ("df" , df [10 :], dropna = True )
258- tm .assert_frame_equal (store ["df" ], df , check_index_type = True )
255+ result = store ["df" ]
256+ expected = df
257+ if using_infer_string :
258+ # TODO: Test is incorrect when not using_infer_string.
259+ # Should take the last 4 rows uncondiationally.
260+ expected = expected [- 4 :]
261+ tm .assert_frame_equal (result , expected , check_index_type = True )
259262
260263 _maybe_remove (store , "df2" )
261264 store .append ("df2" , df [:10 ], dropna = False )
@@ -294,7 +297,7 @@ def test_append_frame_column_oriented(setup_path, request):
294297 # column oriented
295298 df = DataFrame (
296299 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
297- columns = Index (list ("ABCD" ), dtype = object ),
300+ columns = Index (list ("ABCD" )),
298301 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
299302 )
300303 df .index = df .index ._with_freq (None ) # freq doesn't round-trip
@@ -426,7 +429,7 @@ def check_col(key, name, size):
426429 {
427430 "A" : [0.0 , 1.0 , 2.0 , 3.0 , 4.0 ],
428431 "B" : [0.0 , 1.0 , 0.0 , 1.0 , 0.0 ],
429- "C" : Index (["foo1" , "foo2" , "foo3" , "foo4" , "foo5" ], dtype = object ),
432+ "C" : Index (["foo1" , "foo2" , "foo3" , "foo4" , "foo5" ]),
430433 "D" : date_range ("20130101" , periods = 5 ),
431434 }
432435 ).set_index ("C" )
@@ -453,7 +456,7 @@ def check_col(key, name, size):
453456 _maybe_remove (store , "df" )
454457 df = DataFrame (
455458 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
456- columns = Index (list ("ABCD" ), dtype = object ),
459+ columns = Index (list ("ABCD" )),
457460 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
458461 )
459462 df ["string" ] = "foo"
@@ -513,11 +516,12 @@ def test_append_with_empty_string(setup_path):
513516 tm .assert_frame_equal (store .select ("df" ), df )
514517
515518
519+ @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
516520def test_append_with_data_columns (setup_path ):
517521 with ensure_clean_store (setup_path ) as store :
518522 df = DataFrame (
519523 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
520- columns = Index (list ("ABCD" ), dtype = object ),
524+ columns = Index (list ("ABCD" )),
521525 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
522526 )
523527 df .iloc [0 , df .columns .get_loc ("B" )] = 1.0
@@ -693,8 +697,8 @@ def test_append_misc(setup_path):
693697 with ensure_clean_store (setup_path ) as store :
694698 df = DataFrame (
695699 1.1 * np .arange (120 ).reshape ((30 , 4 )),
696- columns = Index (list ("ABCD" ), dtype = object ),
697- index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
700+ columns = Index (list ("ABCD" )),
701+ index = Index ([f"i-{ i } " for i in range (30 )]),
698702 )
699703 store .append ("df" , df , chunksize = 1 )
700704 result = store .select ("df" )
@@ -710,8 +714,8 @@ def test_append_misc_chunksize(setup_path, chunksize):
710714 # more chunksize in append tests
711715 df = DataFrame (
712716 1.1 * np .arange (120 ).reshape ((30 , 4 )),
713- columns = Index (list ("ABCD" ), dtype = object ),
714- index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
717+ columns = Index (list ("ABCD" )),
718+ index = Index ([f"i-{ i } " for i in range (30 )]),
715719 )
716720 df ["string" ] = "foo"
717721 df ["float322" ] = 1.0
@@ -747,15 +751,15 @@ def test_append_misc_empty_frame(setup_path):
747751 tm .assert_frame_equal (store .select ("df2" ), df )
748752
749753
750- def test_append_raise (setup_path ):
754+ def test_append_raise (setup_path , using_infer_string ):
751755 with ensure_clean_store (setup_path ) as store :
752756 # test append with invalid input to get good error messages
753757
754758 # list in column
755759 df = DataFrame (
756760 1.1 * np .arange (120 ).reshape ((30 , 4 )),
757- columns = Index (list ("ABCD" ), dtype = object ),
758- index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
761+ columns = Index (list ("ABCD" )),
762+ index = Index ([f"i-{ i } " for i in range (30 )]),
759763 )
760764 df ["invalid" ] = [["a" ]] * len (df )
761765 assert df .dtypes ["invalid" ] == np .object_
@@ -775,8 +779,8 @@ def test_append_raise(setup_path):
775779 # datetime with embedded nans as object
776780 df = DataFrame (
777781 1.1 * np .arange (120 ).reshape ((30 , 4 )),
778- columns = Index (list ("ABCD" ), dtype = object ),
779- index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
782+ columns = Index (list ("ABCD" )),
783+ index = Index ([f"i-{ i } " for i in range (30 )]),
780784 )
781785 s = Series (datetime .datetime (2001 , 1 , 2 ), index = df .index )
782786 s = s .astype (object )
@@ -803,8 +807,8 @@ def test_append_raise(setup_path):
803807 # appending an incompatible table
804808 df = DataFrame (
805809 1.1 * np .arange (120 ).reshape ((30 , 4 )),
806- columns = Index (list ("ABCD" ), dtype = object ),
807- index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
810+ columns = Index (list ("ABCD" )),
811+ index = Index ([f"i-{ i } " for i in range (30 )]),
808812 )
809813 store .append ("df" , df )
810814
@@ -881,7 +885,7 @@ def test_append_with_timedelta(setup_path):
881885def test_append_to_multiple (setup_path ):
882886 df1 = DataFrame (
883887 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
884- columns = Index (list ("ABCD" ), dtype = object ),
888+ columns = Index (list ("ABCD" )),
885889 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
886890 )
887891 df2 = df1 .copy ().rename (columns = "{}_2" .format )
@@ -918,12 +922,12 @@ def test_append_to_multiple(setup_path):
918922def test_append_to_multiple_dropna (setup_path ):
919923 df1 = DataFrame (
920924 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
921- columns = Index (list ("ABCD" ), dtype = object ),
925+ columns = Index (list ("ABCD" )),
922926 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
923927 )
924928 df2 = DataFrame (
925929 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
926- columns = Index (list ("ABCD" ), dtype = object ),
930+ columns = Index (list ("ABCD" )),
927931 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
928932 ).rename (columns = "{}_2" .format )
929933 df1 .iloc [1 , df1 .columns .get_indexer (["A" , "B" ])] = np .nan
@@ -943,7 +947,7 @@ def test_append_to_multiple_dropna(setup_path):
943947def test_append_to_multiple_dropna_false (setup_path ):
944948 df1 = DataFrame (
945949 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
946- columns = Index (list ("ABCD" ), dtype = object ),
950+ columns = Index (list ("ABCD" )),
947951 index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
948952 )
949953 df2 = df1 .copy ().rename (columns = "{}_2" .format )
0 commit comments