File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1969,3 +1969,17 @@ def test_iterator_errors(dirpath):
1969
1969
with pytest .raises (ValueError , match = "chunksize must be set to a positive" ):
1970
1970
with StataReader (dta_file ) as reader :
1971
1971
reader .__next__ ()
1972
+
1973
+
1974
+ def test_iterator_value_labels ():
1975
+ # GH 31544
1976
+ values = ["c_label" , "b_label" ] + ["a_label" ] * 500
1977
+ df = DataFrame ({f"col{ k } " : pd .Categorical (values , ordered = True ) for k in range (2 )})
1978
+ with tm .ensure_clean () as path :
1979
+ df .to_stata (path , write_index = False )
1980
+ reader = pd .read_stata (path , chunksize = 100 )
1981
+ expected = pd .Index (["a_label" , "b_label" , "c_label" ], dtype = "object" )
1982
+ for j , chunk in enumerate (reader ):
1983
+ for i in range (2 ):
1984
+ tm .assert_index_equal (chunk .dtypes [i ].categories , expected )
1985
+ tm .assert_frame_equal (chunk , df .iloc [j * 100 : (j + 1 ) * 100 ])
You can’t perform that action at this time.
0 commit comments