Skip to content

Commit d39e4f8

Browse files
committed
CLN: drop **kwargs from read_excel
1 parent cc63484 commit d39e4f8

File tree

4 files changed

+5
-31
lines changed

4 files changed

+5
-31
lines changed

doc/source/whatsnew/v1.1.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ Backwards incompatible API changes
394394
- :meth:`Series.to_timestamp` now raises a ``TypeError`` if the axis is not a :class:`PeriodIndex`. Previously an ``AttributeError`` was raised (:issue:`33327`)
395395
- :meth:`Series.to_period` now raises a ``TypeError`` if the axis is not a :class:`DatetimeIndex`. Previously an ``AttributeError`` was raised (:issue:`33327`)
396396
- :func: `pandas.api.dtypes.is_string_dtype` no longer incorrectly identifies categorical series as string.
397+
- :func:`read_excel` no longer takes ``**kwds`` arguments. This means that passing in keyword ``chunksize`` now raises a ``TypeError``
398+
(previously raised a ``NotImplementedError``), while passing in keyword ``encoding`` now raises a ``TypeError`` (:issue:`xxxxx`)
397399

398400
``MultiIndex.get_indexer`` interprets `method` argument differently
399401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pandas/io/excel/_base.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ def read_excel(
285285
nrows=None,
286286
na_values=None,
287287
keep_default_na=True,
288+
na_filter=True,
288289
verbose=False,
289290
parse_dates=False,
290291
date_parser=None,
@@ -293,13 +294,8 @@ def read_excel(
293294
skipfooter=0,
294295
convert_float=True,
295296
mangle_dupe_cols=True,
296-
**kwds,
297297
):
298298

299-
for arg in ("sheet", "sheetname", "parse_cols"):
300-
if arg in kwds:
301-
raise TypeError(f"read_excel() got an unexpected keyword argument `{arg}`")
302-
303299
if not isinstance(io, ExcelFile):
304300
io = ExcelFile(io, engine=engine)
305301
elif engine and engine != io.engine:
@@ -323,6 +319,7 @@ def read_excel(
323319
nrows=nrows,
324320
na_values=na_values,
325321
keep_default_na=keep_default_na,
322+
na_filter=na_filter,
326323
verbose=verbose,
327324
parse_dates=parse_dates,
328325
date_parser=date_parser,
@@ -331,7 +328,6 @@ def read_excel(
331328
skipfooter=skipfooter,
332329
convert_float=convert_float,
333330
mangle_dupe_cols=mangle_dupe_cols,
334-
**kwds,
335331
)
336332

337333

@@ -861,11 +857,6 @@ def parse(
861857
DataFrame or dict of DataFrames
862858
DataFrame from the passed in Excel file.
863859
"""
864-
if "chunksize" in kwds:
865-
raise NotImplementedError(
866-
"chunksize keyword of read_excel is not implemented"
867-
)
868-
869860
return self._reader.parse(
870861
sheet_name=sheet_name,
871862
header=header,

pandas/tests/io/excel/test_readers.py

-17
Original file line numberDiff line numberDiff line change
@@ -897,12 +897,6 @@ def test_read_excel_bool_header_arg(self, read_ext):
897897
with pytest.raises(TypeError, match=msg):
898898
pd.read_excel("test1" + read_ext, header=arg)
899899

900-
def test_read_excel_chunksize(self, read_ext):
901-
# GH 8011
902-
msg = "chunksize keyword of read_excel is not implemented"
903-
with pytest.raises(NotImplementedError, match=msg):
904-
pd.read_excel("test1" + read_ext, chunksize=100)
905-
906900
def test_read_excel_skiprows_list(self, read_ext):
907901
# GH 4903
908902
if pd.read_excel.keywords["engine"] == "pyxlsb":
@@ -1048,17 +1042,6 @@ def test_excel_passes_na_filter(self, read_ext, na_filter):
10481042
expected = DataFrame(expected, columns=["Test"])
10491043
tm.assert_frame_equal(parsed, expected)
10501044

1051-
@pytest.mark.parametrize("arg", ["sheet", "sheetname", "parse_cols"])
1052-
@td.check_file_leaks
1053-
def test_unexpected_kwargs_raises(self, read_ext, arg):
1054-
# gh-17964
1055-
kwarg = {arg: "Sheet1"}
1056-
msg = fr"unexpected keyword argument `{arg}`"
1057-
1058-
with pd.ExcelFile("test1" + read_ext) as excel:
1059-
with pytest.raises(TypeError, match=msg):
1060-
pd.read_excel(excel, **kwarg)
1061-
10621045
def test_excel_table_sheet_by_index(self, read_ext, df_ref):
10631046
# For some reason pd.read_excel has no attribute 'keywords' here.
10641047
# Skipping based on read_ext instead.

pandas/tests/io/excel/test_writers.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,7 @@ def test_to_excel_output_encoding(self, ext):
836836

837837
with tm.ensure_clean("__tmp_to_excel_float_format__." + ext) as filename:
838838
df.to_excel(filename, sheet_name="TestSheet", encoding="utf8")
839-
result = pd.read_excel(
840-
filename, sheet_name="TestSheet", encoding="utf8", index_col=0
841-
)
839+
result = pd.read_excel(filename, sheet_name="TestSheet", index_col=0)
842840
tm.assert_frame_equal(result, df)
843841

844842
def test_to_excel_unicode_filename(self, ext, path):

0 commit comments

Comments
 (0)