Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX-#6637: Fix skiprows parameter usage for read_excel #6638

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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