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

DEPR: deprecate non keyword arguments in read_excel #34418

Merged
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
4 changes: 4 additions & 0 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ Deprecations
version 1.1. All other arguments should be given as keyword
arguments (:issue:`27573`).

- Passing any arguments but the first 2 to :func:`read_excel` as
positional arguments is deprecated since version 1.1. All other
arguments should be given as keyword arguments (:issue:`27573`).

- :func:`pandas.api.types.is_categorical` is deprecated and will be removed in a future version; use `:func:pandas.api.types.is_categorical_dtype` instead (:issue:`33385`)
- :meth:`Index.get_value` is deprecated and will be removed in a future version (:issue:`19728`)
- :meth:`DateOffset.__call__` is deprecated and will be removed in a future version, use ``offset + other`` instead (:issue:`34171`)
Expand Down
3 changes: 2 additions & 1 deletion pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from pandas._libs.parsers import STR_NA_VALUES
from pandas.errors import EmptyDataError
from pandas.util._decorators import Appender
from pandas.util._decorators import Appender, deprecate_nonkeyword_arguments

from pandas.core.dtypes.common import is_bool, is_float, is_integer, is_list_like

Expand Down Expand Up @@ -266,6 +266,7 @@
)


@deprecate_nonkeyword_arguments(allowed_args=2, version="2.0")
@Appender(_read_excel_doc)
def read_excel(
io,
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/excel/test_odf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_read_writer_table():
columns=["Column 1", "Unnamed: 2", "Column 3"],
)

result = pd.read_excel("writertable.odt", "Table1", index_col=0)
result = pd.read_excel("writertable.odt", sheet_name="Table1", index_col=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sheet_name required to be passed like this or still OK positionally? I assume the latter from allowed_args being 2 but maybe am misreading

+/- 0 on making this required as a keyword argument. It would seem a rather natural positional argument so maybe not worth the churn, but not a strong opinion

Copy link
Contributor Author

@topper-123 topper-123 May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sheet_name required to be passed like this or still OK positionally?

This is just a cleanup, I think it's more readable with keyword arguments.

I think exel files are very well known, so people will easily infer that the second parameter is the sheet name, and making positional argument for sheet_name fail, e.g. in jupyter notebook could maybe be seen as too restrictive. This is not a strong opinion, so if making it a required kwarg is seen as better, I can do that.


tm.assert_frame_equal(result, expected)

Expand Down
Loading