Exemplo n.º 1
0
    def _save_chunk(self, start_i, end_i):

        data_index = self.data_index

        # create the data for a chunk
        slicer = slice(start_i, end_i)
        for i in range(len(self.blocks)):
            b = self.blocks[i]
            d = b.to_native_types(slicer=slicer, na_rep=self.na_rep,
                                  float_format=self.float_format,
                                  decimal=self.decimal,
                                  date_format=self.date_format,
                                  quoting=self.quoting)

            for col_loc, col in zip(b.mgr_locs, d):
                # self.data is a preallocated list
                self.data[col_loc] = col

        ix = data_index.to_native_types(slicer=slicer, na_rep=self.na_rep,
                                        float_format=self.float_format,
                                        decimal=self.decimal,
                                        date_format=self.date_format,
                                        quoting=self.quoting)

        libwriters.write_csv_rows(self.data, ix, self.nlevels,
                                  self.cols, self.writer)
Exemplo n.º 2
0
    def _save_chunk(self, start_i: int, end_i: int) -> None:
        data_index = self.data_index

        # create the data for a chunk
        slicer = slice(start_i, end_i)
        for i in range(len(self.blocks)):
            b = self.blocks[i]
            d = b.to_native_types(
                slicer=slicer,
                na_rep=self.na_rep,
                float_format=self.float_format,
                decimal=self.decimal,
                date_format=self.date_format,
                quoting=self.quoting,
            )

            for col_loc, col in zip(b.mgr_locs, d):
                # self.data is a preallocated list
                self.data[col_loc] = col

        ix = data_index.to_native_types(
            slicer=slicer,
            na_rep=self.na_rep,
            float_format=self.float_format,
            decimal=self.decimal,
            date_format=self.date_format,
            quoting=self.quoting,
        )

        libwriters.write_csv_rows(self.data, ix, self.nlevels, self.cols,
                                  self.writer)
Exemplo n.º 3
0
    def _save_chunk(self, start_i, end_i):

        data_index = self.data_index

        # create the data for a chunk
        slicer = slice(start_i, end_i)
        for i in range(len(self.blocks)):
            b = self.blocks[i]
            # DKU-specific : force date format to include timezone when available
            if b.is_datetimetz:
                date_format = '%Y-%m-%dT%H:%M:%S.%f%z'
            else:
                date_format = self.date_format
            d = b.to_native_types(slicer=slicer,
                                  na_rep=self.na_rep,
                                  float_format=self.float_format,
                                  decimal=self.decimal,
                                  date_format=date_format,
                                  quoting=self.quoting)

            for col_loc, col in zip(b.mgr_locs, d):
                # self.data is a preallocated list
                self.data[col_loc] = col

        ix = data_index.to_native_types(slicer=slicer,
                                        na_rep=self.na_rep,
                                        float_format=self.float_format,
                                        date_format=self.date_format,
                                        quoting=self.quoting)

        libwriters.write_csv_rows(self.data, ix, self.nlevels, self.cols,
                                  self.writer)
Exemplo n.º 4
0
    def _save_chunk(self, start_i: int, end_i: int) -> None:
        # create the data for a chunk
        slicer = slice(start_i, end_i)
        df = self.obj.iloc[slicer]

        res = df._mgr.to_native_types(**self._number_format)
        data = [res.iget_values(i) for i in range(len(res.items))]

        ix = self.data_index[slicer]._format_native_types(**self._number_format)
        libwriters.write_csv_rows(data, ix, self.nlevels, self.cols, self.writer)
Exemplo n.º 5
0
    def _save_chunk(self, start_i: int, end_i: int) -> None:
        ncols = self.obj.shape[-1]
        data = [None] * ncols

        # create the data for a chunk
        slicer = slice(start_i, end_i)

        df = self.obj.iloc[slicer]
        mgr = df._mgr

        res = mgr.apply("to_native_types", **self._number_format)
        for i in range(len(res.items)):
            data[i] = res.iget_values(i)

        ix = self.data_index.to_native_types(slicer=slicer,
                                             **self._number_format)
        libwriters.write_csv_rows(data, ix, self.nlevels, self.cols,
                                  self.writer)
Exemplo n.º 6
0
    def _save_chunk(self, start_i: int, end_i: int) -> None:
        # create the data for a chunk
        slicer = slice(start_i, end_i)
        df = self.obj.iloc[slicer]

        res = df._mgr.to_native_types(**self._number_format)
        data = [res.iget_values(i) for i in range(len(res.items))]

        ix = self.data_index[slicer]._format_native_types(
            **self._number_format)
        # error: Argument 4 to "write_csv_rows" has incompatible type
        # "Sequence[Hashable]"; expected "ndarray"
        libwriters.write_csv_rows(
            data,
            ix,
            self.nlevels,
            self.cols,  # type: ignore[arg-type]
            self.writer,
        )
Exemplo n.º 7
0
    def _save_chunk(self, start_i: int, end_i: int) -> None:
        ncols = self.obj.shape[-1]
        data = [None] * ncols

        # create the data for a chunk
        slicer = slice(start_i, end_i)

        df = self.obj.iloc[slicer]

        for block in df._mgr.blocks:
            d = block.to_native_types(**self._number_format)

            for col_loc, col in zip(block.mgr_locs, d):
                data[col_loc] = col

        ix = self.data_index.to_native_types(slicer=slicer,
                                             **self._number_format)
        libwriters.write_csv_rows(data, ix, self.nlevels, self.cols,
                                  self.writer)