Skip to content

Commit

Permalink
FIX-#6637: Fix 'skiprows' parameter usage for 'read_excel' (#6638)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Oct 9, 2023
1 parent bc7f7d2 commit a01ce30
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions modin/core/io/text/excel_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def _read(cls, io, **kwargs):
**kwargs
)

if kwargs.get("skiprows") is not None:
return cls.single_worker_read(
io,
reason="Modin doesn't support 'skiprows' parameter of `read_excel`",
**kwargs
)

if isinstance(io, bytes):
io = BytesIO(io)

Expand Down
3 changes: 2 additions & 1 deletion modin/core/storage_formats/pandas/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ def parse(fname, **kwargs):
num_splits = kwargs.pop("num_splits", None)
start = kwargs.pop("start", None)
end = kwargs.pop("end", None)
_skiprows = kwargs.pop("skiprows")
excel_header = kwargs.get("_header")
sheet_name = kwargs.get("sheet_name", 0)
footer = b"</sheetData></worksheet>"
Expand All @@ -589,6 +588,8 @@ def parse(fname, **kwargs):
if start is None or end is None:
return pandas.read_excel(fname, **kwargs)

_skiprows = kwargs.pop("skiprows")

import re
from zipfile import ZipFile

Expand Down
11 changes: 11 additions & 0 deletions modin/pandas/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,17 @@ def test_read_excel(self, pathlike, make_excel_file):
io=Path(unique_filename) if pathlike else unique_filename,
)

@check_file_leaks
@pytest.mark.parametrize("skiprows", [2, [1, 3], lambda x: x in [0, 2]])
def test_read_excel_skiprows(self, skiprows, make_excel_file):
eval_io(
fn_name="read_excel",
# read_excel kwargs
io=make_excel_file(),
skiprows=skiprows,
check_kwargs_callable=False,
)

@check_file_leaks
@pytest.mark.parametrize(
"dtype_backend", [lib.no_default, "numpy_nullable", "pyarrow"]
Expand Down

0 comments on commit a01ce30

Please sign in to comment.