@@ -820,21 +820,7 @@ def __init__(self, obj, path_or_buf, sep=",", na_rep='', float_format=None,
820
820
self .blocks = self .obj ._data .blocks
821
821
ncols = sum (len (b .items ) for b in self .blocks )
822
822
self .data = [None ] * ncols
823
-
824
- if self .obj .columns .is_unique :
825
- self .colname_map = dict ((k ,i ) for i ,k in enumerate (self .obj .columns ))
826
- else :
827
- ks = [set (x .items ) for x in self .blocks ]
828
- u = len (reduce (lambda a ,x : a .union (x ),ks ,set ()))
829
- t = sum (map (len ,ks ))
830
- if u != t :
831
- if len (set (self .cols )) != len (self .cols ):
832
- raise NotImplementedError ("duplicate columns with differing dtypes are unsupported" )
833
- else :
834
- # if columns are not unique and we acces this,
835
- # we're doing it wrong
836
- pass
837
-
823
+ self .column_map = self .obj ._data .get_items_map ()
838
824
839
825
if chunksize is None :
840
826
chunksize = (100000 / (len (self .cols ) or 1 )) or 1
@@ -1034,18 +1020,13 @@ def _save_chunk(self, start_i, end_i):
1034
1020
1035
1021
# create the data for a chunk
1036
1022
slicer = slice (start_i ,end_i )
1037
- if self .obj .columns .is_unique :
1038
- for i in range (len (self .blocks )):
1039
- b = self .blocks [i ]
1040
- d = b .to_native_types (slicer = slicer , na_rep = self .na_rep , float_format = self .float_format )
1041
- for j , k in enumerate (b .items ):
1042
- # self.data is a preallocated list
1043
- self .data [self .colname_map [k ]] = d [j ]
1044
- else :
1045
- # self.obj should contain a proper view of the dataframes
1046
- # with the specified ordering of cols if cols was specified
1047
- for i in range (len (self .obj .columns )):
1048
- self .data [i ] = self .obj .icol (i ).values [slicer ].tolist ()
1023
+ for i in range (len (self .blocks )):
1024
+ b = self .blocks [i ]
1025
+ d = b .to_native_types (slicer = slicer , na_rep = self .na_rep , float_format = self .float_format )
1026
+ for i , item in enumerate (b .items ):
1027
+
1028
+ # self.data is a preallocated list
1029
+ self .data [self .column_map [b ][i ]] = d [i ]
1049
1030
1050
1031
ix = data_index .to_native_types (slicer = slicer , na_rep = self .na_rep , float_format = self .float_format )
1051
1032
0 commit comments