@@ -234,10 +234,11 @@ def test_read_dta4(self):
234
234
expected = pd .concat ([expected [col ].astype ('category' )
235
235
for col in expected ], axis = 1 )
236
236
237
- tm .assert_frame_equal (parsed_113 , expected )
238
- tm .assert_frame_equal (parsed_114 , expected )
239
- tm .assert_frame_equal (parsed_115 , expected )
240
- tm .assert_frame_equal (parsed_117 , expected )
237
+ # stata doesn't save .category metadata
238
+ tm .assert_frame_equal (parsed_113 , expected , check_categorical = False )
239
+ tm .assert_frame_equal (parsed_114 , expected , check_categorical = False )
240
+ tm .assert_frame_equal (parsed_115 , expected , check_categorical = False )
241
+ tm .assert_frame_equal (parsed_117 , expected , check_categorical = False )
241
242
242
243
# File containing strls
243
244
def test_read_dta12 (self ):
@@ -872,8 +873,8 @@ def test_categorical_writing(self):
872
873
# Silence warnings
873
874
original .to_stata (path )
874
875
written_and_read_again = self .read_dta (path )
875
- tm . assert_frame_equal (
876
- written_and_read_again . set_index ( 'index' ) , expected )
876
+ res = written_and_read_again . set_index ( 'index' )
877
+ tm . assert_frame_equal ( res , expected , check_categorical = False )
877
878
878
879
def test_categorical_warnings_and_errors (self ):
879
880
# Warning for non-string labels
@@ -915,8 +916,8 @@ def test_categorical_with_stata_missing_values(self):
915
916
with tm .ensure_clean () as path :
916
917
original .to_stata (path )
917
918
written_and_read_again = self .read_dta (path )
918
- tm . assert_frame_equal (
919
- written_and_read_again . set_index ( 'index' ) , original )
919
+ res = written_and_read_again . set_index ( 'index' )
920
+ tm . assert_frame_equal ( res , original , check_categorical = False )
920
921
921
922
def test_categorical_order (self ):
922
923
# Directly construct using expected codes
@@ -945,8 +946,8 @@ def test_categorical_order(self):
945
946
# Read with and with out categoricals, ensure order is identical
946
947
parsed_115 = read_stata (self .dta19_115 )
947
948
parsed_117 = read_stata (self .dta19_117 )
948
- tm .assert_frame_equal (expected , parsed_115 )
949
- tm .assert_frame_equal (expected , parsed_117 )
949
+ tm .assert_frame_equal (expected , parsed_115 , check_categorical = False )
950
+ tm .assert_frame_equal (expected , parsed_117 , check_categorical = False )
950
951
951
952
# Check identity of codes
952
953
for col in expected :
@@ -969,8 +970,10 @@ def test_categorical_sorting(self):
969
970
categories = ["Poor" , "Fair" , "Good" , "Very good" , "Excellent" ]
970
971
cat = pd .Categorical .from_codes (codes = codes , categories = categories )
971
972
expected = pd .Series (cat , name = 'srh' )
972
- tm .assert_series_equal (expected , parsed_115 ["srh" ])
973
- tm .assert_series_equal (expected , parsed_117 ["srh" ])
973
+ tm .assert_series_equal (expected , parsed_115 ["srh" ],
974
+ check_categorical = False )
975
+ tm .assert_series_equal (expected , parsed_117 ["srh" ],
976
+ check_categorical = False )
974
977
975
978
def test_categorical_ordering (self ):
976
979
parsed_115 = read_stata (self .dta19_115 )
@@ -1021,7 +1024,8 @@ def test_read_chunks_117(self):
1021
1024
from_frame = parsed .iloc [pos :pos + chunksize , :]
1022
1025
tm .assert_frame_equal (
1023
1026
from_frame , chunk , check_dtype = False ,
1024
- check_datetimelike_compat = True )
1027
+ check_datetimelike_compat = True ,
1028
+ check_categorical = False )
1025
1029
1026
1030
pos += chunksize
1027
1031
itr .close ()
@@ -1087,7 +1091,8 @@ def test_read_chunks_115(self):
1087
1091
from_frame = parsed .iloc [pos :pos + chunksize , :]
1088
1092
tm .assert_frame_equal (
1089
1093
from_frame , chunk , check_dtype = False ,
1090
- check_datetimelike_compat = True )
1094
+ check_datetimelike_compat = True ,
1095
+ check_categorical = False )
1091
1096
1092
1097
pos += chunksize
1093
1098
itr .close ()
0 commit comments