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

CLN: drop **kwds from pd.read_excel #34464

Merged
merged 2 commits into from
Jun 1, 2020
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
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ Backwards incompatible API changes
- :meth:`Series.to_timestamp` now raises a ``TypeError`` if the axis is not a :class:`PeriodIndex`. Previously an ``AttributeError`` was raised (:issue:`33327`)
- :meth:`Series.to_period` now raises a ``TypeError`` if the axis is not a :class:`DatetimeIndex`. Previously an ``AttributeError`` was raised (:issue:`33327`)
- :func: `pandas.api.dtypes.is_string_dtype` no longer incorrectly identifies categorical series as string.
- :func:`read_excel` no longer takes ``**kwds`` arguments. This means that passing in keyword ``chunksize`` now raises a ``TypeError``
(previously raised a ``NotImplementedError``), while passing in keyword ``encoding`` now raises a ``TypeError`` (:issue:`34464`)

``MultiIndex.get_indexer`` interprets `method` argument differently
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
15 changes: 2 additions & 13 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@
Duplicate columns will be specified as 'X', 'X.1', ...'X.N', rather than
'X'...'X'. Passing in False will cause data to be overwritten if there
are duplicate names in the columns.
**kwds : optional
Optional keyword arguments can be passed to ``TextFileReader``.

Returns
-------
Expand Down Expand Up @@ -285,6 +283,7 @@ def read_excel(
nrows=None,
na_values=None,
keep_default_na=True,
na_filter=True,
verbose=False,
parse_dates=False,
date_parser=None,
Expand All @@ -293,13 +292,8 @@ def read_excel(
skipfooter=0,
convert_float=True,
mangle_dupe_cols=True,
**kwds,
):

for arg in ("sheet", "sheetname", "parse_cols"):
if arg in kwds:
raise TypeError(f"read_excel() got an unexpected keyword argument `{arg}`")

if not isinstance(io, ExcelFile):
io = ExcelFile(io, engine=engine)
elif engine and engine != io.engine:
Expand All @@ -323,6 +317,7 @@ def read_excel(
nrows=nrows,
na_values=na_values,
keep_default_na=keep_default_na,
na_filter=na_filter,
verbose=verbose,
parse_dates=parse_dates,
date_parser=date_parser,
Expand All @@ -331,7 +326,6 @@ def read_excel(
skipfooter=skipfooter,
convert_float=convert_float,
mangle_dupe_cols=mangle_dupe_cols,
**kwds,
)


Expand Down Expand Up @@ -861,11 +855,6 @@ def parse(
DataFrame or dict of DataFrames
DataFrame from the passed in Excel file.
"""
if "chunksize" in kwds:
raise NotImplementedError(
"chunksize keyword of read_excel is not implemented"
)

return self._reader.parse(
sheet_name=sheet_name,
header=header,
Expand Down
17 changes: 0 additions & 17 deletions pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,12 +897,6 @@ def test_read_excel_bool_header_arg(self, read_ext):
with pytest.raises(TypeError, match=msg):
pd.read_excel("test1" + read_ext, header=arg)

def test_read_excel_chunksize(self, read_ext):
jreback marked this conversation as resolved.
Show resolved Hide resolved
# GH 8011
msg = "chunksize keyword of read_excel is not implemented"
with pytest.raises(NotImplementedError, match=msg):
pd.read_excel("test1" + read_ext, chunksize=100)

def test_read_excel_skiprows_list(self, read_ext):
# GH 4903
if pd.read_excel.keywords["engine"] == "pyxlsb":
Expand Down Expand Up @@ -1048,17 +1042,6 @@ def test_excel_passes_na_filter(self, read_ext, na_filter):
expected = DataFrame(expected, columns=["Test"])
tm.assert_frame_equal(parsed, expected)

@pytest.mark.parametrize("arg", ["sheet", "sheetname", "parse_cols"])
@td.check_file_leaks
def test_unexpected_kwargs_raises(self, read_ext, arg):
# gh-17964
kwarg = {arg: "Sheet1"}
msg = fr"unexpected keyword argument `{arg}`"

with pd.ExcelFile("test1" + read_ext) as excel:
with pytest.raises(TypeError, match=msg):
pd.read_excel(excel, **kwarg)

def test_excel_table_sheet_by_index(self, read_ext, df_ref):
# For some reason pd.read_excel has no attribute 'keywords' here.
# Skipping based on read_ext instead.
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,7 @@ def test_to_excel_output_encoding(self, ext):

with tm.ensure_clean("__tmp_to_excel_float_format__." + ext) as filename:
df.to_excel(filename, sheet_name="TestSheet", encoding="utf8")
result = pd.read_excel(
filename, sheet_name="TestSheet", encoding="utf8", index_col=0
)
result = pd.read_excel(filename, sheet_name="TestSheet", index_col=0)
tm.assert_frame_equal(result, df)

def test_to_excel_unicode_filename(self, ext, path):
Expand Down