-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
PERF: Optimize read_excel nrows #46894
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
Changes from 14 commits
6fd0422
e4d52d8
eb83a74
2c643c7
dc14ac2
2e79141
943f866
10a8a3e
30a280c
bbc1f1d
2018d26
c108a97
3aad835
7c913d6
d6e1df3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,13 +120,7 @@ def __init__(self, kwds) -> None: | |
|
||
# validate header options for mi | ||
self.header = kwds.get("header") | ||
if isinstance(self.header, (list, tuple, np.ndarray)): | ||
if not all(map(is_integer, self.header)): | ||
raise ValueError("header must be integer or list of integers") | ||
if any(i < 0 for i in self.header): | ||
raise ValueError( | ||
"cannot specify multi-index header with negative integers" | ||
) | ||
Comment on lines
-123
to
-129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be missing it, is validate_header_arg called somewhere instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but it took me a while to find it. It's called earlier in TextFileReader:
|
||
if is_list_like(self.header): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allow_sets=False |
||
if kwds.get("usecols"): | ||
raise ValueError( | ||
"cannot specify usecols when specifying a multi-index header" | ||
|
@@ -138,31 +132,20 @@ def __init__(self, kwds) -> None: | |
|
||
# validate index_col that only contains integers | ||
if self.index_col is not None: | ||
is_sequence = isinstance(self.index_col, (list, tuple, np.ndarray)) | ||
if not ( | ||
is_sequence | ||
is_list_like(self.index_col) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allow_sets=False |
||
and all(map(is_integer, self.index_col)) | ||
or is_integer(self.index_col) | ||
): | ||
raise ValueError( | ||
"index_col must only contain row numbers " | ||
"when specifying a multi-index header" | ||
) | ||
elif self.header is not None: | ||
elif self.header is not None and self.prefix is not None: | ||
# GH 27394 | ||
if self.prefix is not None: | ||
raise ValueError( | ||
"Argument prefix must be None if argument header is not None" | ||
) | ||
# GH 16338 | ||
elif not is_integer(self.header): | ||
raise ValueError("header must be integer or list of integers") | ||
# GH 27779 | ||
elif self.header < 0: | ||
raise ValueError( | ||
"Passing negative integer to header is invalid. " | ||
"For no header, use header=None instead" | ||
) | ||
raise ValueError( | ||
"Argument prefix must be None if argument header is not None" | ||
) | ||
|
||
self._name_processed = False | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.