@@ -789,7 +789,7 @@ def _chunk_to_dataframe(self) -> DataFrame:
789
789
n = self ._current_row_in_chunk_index
790
790
m = self ._current_row_in_file_index
791
791
ix = range (m - n , m )
792
- rslt = DataFrame ( index = ix )
792
+ rslt = {}
793
793
794
794
js , jb = 0 , 0
795
795
for j in range (self .column_count ):
@@ -798,25 +798,26 @@ def _chunk_to_dataframe(self) -> DataFrame:
798
798
799
799
if self ._column_types [j ] == b"d" :
800
800
rslt [name ] = self ._byte_chunk [jb , :].view (dtype = self .byte_order + "d" )
801
- rslt [name ] = np . asarray (rslt [name ], dtype = np .float64 )
801
+ rslt [name ] = pd . Series (rslt [name ], dtype = np .float64 , index = ix )
802
802
if self .convert_dates :
803
803
if self .column_formats [j ] in const .sas_date_formats :
804
804
rslt [name ] = _convert_datetimes (rslt [name ], "d" )
805
805
elif self .column_formats [j ] in const .sas_datetime_formats :
806
806
rslt [name ] = _convert_datetimes (rslt [name ], "s" )
807
807
jb += 1
808
808
elif self ._column_types [j ] == b"s" :
809
- rslt [name ] = self ._string_chunk [js , :]
809
+ rslt [name ] = pd . Series ( self ._string_chunk [js , :], index = ix )
810
810
if self .convert_text and (self .encoding is not None ):
811
811
rslt [name ] = rslt [name ].str .decode (
812
812
self .encoding or self .default_encoding
813
813
)
814
814
if self .blank_missing :
815
815
ii = rslt [name ].str .len () == 0
816
- rslt . loc [ ii , name ] = np .nan
816
+ rslt [ name ][ ii ] = np .nan
817
817
js += 1
818
818
else :
819
819
self .close ()
820
820
raise ValueError (f"unknown column type { self ._column_types [j ]} " )
821
821
822
- return rslt
822
+ df = DataFrame (rslt , columns = self .column_names , index = ix , copy = False )
823
+ return df
0 commit comments