Skip to content

Commit 75b2d54

Browse files
committed
Implement column chunking
Signed-off-by: Vasily Litvinov <vasilij.n.litvinov@intel.com>
1 parent 4f13176 commit 75b2d54

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pandas/api/exchange/implementation.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,15 @@ def get_chunks(self, n_chunks=None):
405405
Return an iterator yielding the chunks.
406406
See `DataFrame.get_chunks` for details on ``n_chunks``.
407407
"""
408-
# TODO: implement proper chunking for n_chunks > 1
409-
return (self,)
408+
if n_chunks and n_chunks > 1:
409+
size = len(self._col)
410+
step = size // n_chunks
411+
if size % n_chunks != 0:
412+
step +=1
413+
for start in range(0, step * n_chunks, step):
414+
yield _PandasColumn(self._col.iloc[start:start + step], self._allow_copy)
415+
else:
416+
yield self
410417

411418
def get_buffers(self):
412419
"""

0 commit comments

Comments
 (0)