-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG : Add Deprecation FutureWarning for parse function call in read_excel #51437
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 6 commits
098cb6b
ed722f3
e5b6093
e497e48
50178ff
e989751
5877d88
e2e8645
0fb4f50
0cac04e
c6d7813
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
cast, | ||
overload, | ||
) | ||
import warnings | ||
import zipfile | ||
|
||
from pandas._config import ( | ||
|
@@ -47,6 +48,7 @@ | |
Appender, | ||
doc, | ||
) | ||
from pandas.util._exceptions import find_stack_level | ||
|
||
from pandas.core.dtypes.common import ( | ||
is_bool, | ||
|
@@ -1564,6 +1566,9 @@ def parse( | |
""" | ||
Parse specified sheet(s) into a DataFrame. | ||
|
||
.. deprecated:: 2.0.0 | ||
Arguments other than sheet_name by position may not work. | ||
|
||
Equivalent to read_excel(ExcelFile, ...) See the read_excel | ||
docstring for more info on accepted parameters. | ||
|
||
|
@@ -1572,6 +1577,41 @@ def parse( | |
DataFrame or dict of DataFrames | ||
DataFrame from the passed in Excel file. | ||
""" | ||
arguments = list(kwds.keys()) | ||
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. This isn't necessary, just iterated over kwds below: |
||
allowed_kwargs = [ | ||
pacificdragon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"sheet_name", | ||
"header", | ||
"names", | ||
"index_col", | ||
"usecols", | ||
"squeeze", | ||
"dtype", | ||
"engine", | ||
"converters", | ||
"true_values", | ||
"false_values", | ||
"skiprows", | ||
"nrows", | ||
"na_values", | ||
"keep_default_na", | ||
"na_filter", | ||
"verbose", | ||
"parse_dates", | ||
"date_parser", | ||
"thousands", | ||
"decimal", | ||
"comment", | ||
"skipfooter", | ||
"convert_float", | ||
] | ||
# Check for any invalid kwargs | ||
if [argument for argument in arguments if argument not in allowed_kwargs]: | ||
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.
|
||
warnings.warn( | ||
f"{type(self).__name__}.parse is deprecated. " | ||
"Arguments other than sheet_name by position may not work.", | ||
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. This method is not deprecated, right? Just passing invalid arguments and passing arguments by position. |
||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
return self._reader.parse( | ||
sheet_name=sheet_name, | ||
header=header, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying arguments other than sheet_name by position is deprecated. Specify arguments by keyword name instead.