Skip to content

Commit f4e27b3

Browse files
committed
BUG: Handle sheetname deprecation directly
Since sheetname=None has a special meaning, we can't use the deprecate_kwargs decorator. We instead handle it in read_excel.
1 parent cfcc66e commit f4e27b3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/io/excel.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import os
1010
import abc
11+
import warnings
1112
import numpy as np
1213

1314
from pandas.core.dtypes.common import (
@@ -193,7 +194,6 @@ def get_writer(engine_name):
193194
raise ValueError("No Excel writer '%s'" % engine_name)
194195

195196

196-
@deprecate_kwarg('sheetname', 'sheet_name')
197197
@Appender(_read_excel_doc)
198198
def read_excel(io, sheet_name=0, header=0, skiprows=None, skip_footer=0,
199199
index_col=None, names=None, parse_cols=None, parse_dates=False,
@@ -202,6 +202,16 @@ def read_excel(io, sheet_name=0, header=0, skiprows=None, skip_footer=0,
202202
dtype=None, true_values=None, false_values=None, engine=None,
203203
squeeze=False, **kwds):
204204

205+
# Can't use _deprecate_kwarg since sheetname=None has a special meaning
206+
if sheet_name is 0 and 'sheetname' in kwds:
207+
# deprecation warning
208+
warnings.warn("The `sheetname` keyword is deprecated, use "
209+
"`sheet_name` instead", FutureWarning)
210+
sheet_name = kwds.pop("sheetname")
211+
elif 'sheetname' in kwds:
212+
raise TypeError("Cannot specify both `sheet_name` and `sheetname`. "
213+
"Use just `sheet_name`")
214+
205215
if not isinstance(io, ExcelFile):
206216
io = ExcelFile(io, engine=engine)
207217

0 commit comments

Comments
 (0)