@@ -1053,7 +1053,8 @@ def test_iterator(self):
1053
tm .assert_frame_equal (parsed .iloc [0 :5 , :], chunk )
1053
tm .assert_frame_equal (parsed .iloc [0 :5 , :], chunk )
1054
1054
1055
# GH12153
1055
# GH12153
1056
- from_chunks = pd .concat (read_stata (fname , chunksize = 4 ))
1056
+ with read_stata (fname , chunksize = 4 ) as itr :
1057
+ from_chunks = pd .concat (itr )
1057
tm .assert_frame_equal (parsed , from_chunks )
1058
tm .assert_frame_equal (parsed , from_chunks )
1058
1059
1059
def test_read_chunks_115 (self ):
1060
def test_read_chunks_115 (self ):
@@ -1306,8 +1307,9 @@ def test_value_labels_iterator(self, write_index):
1306
df ['A' ] = df ['A' ].astype ('category' )
1307
df ['A' ] = df ['A' ].astype ('category' )
1307
with tm .ensure_clean () as path :
1308
with tm .ensure_clean () as path :
1308
df .to_stata (path , write_index = write_index )
1309
df .to_stata (path , write_index = write_index )
1309
- dta_iter = pd .read_stata (path , iterator = True )
1310
+
1310
- value_labels = dta_iter .value_labels ()
1311
+ with pd .read_stata (path , iterator = True ) as dta_iter :
1312
+ value_labels = dta_iter .value_labels ()
1311
assert value_labels == {'A' : {0 : 'A' , 1 : 'B' , 2 : 'C' , 3 : 'E' }}
1313
assert value_labels == {'A' : {0 : 'A' , 1 : 'B' , 2 : 'C' , 3 : 'E' }}
1312
1314
1313
def test_set_index (self ):
1315
def test_set_index (self ):
0 commit comments