Skip to content

Commit 9d6d959

Browse files
mroeschkeanother-green
authored andcommitted
CLN: Remove deprecated parse_cols from read_excel (pandas-dev#26522)
xref pandas-devgh-6581
1 parent 8c8a175 commit 9d6d959

File tree

3 files changed

+4
-32
lines changed

3 files changed

+4
-32
lines changed

doc/source/whatsnew/v0.25.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ Removal of prior version deprecations/changes
313313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314314
- Removed ``Panel`` (:issue:`25047`, :issue:`25191`, :issue:`25231`)
315315
- Removed the previously deprecated ``sheetname`` keyword in :func:`read_excel` (:issue:`16442`, :issue:`20938`)
316-
- Removed previously deprecated ``TimeGrouper`` (:issue:`16942`)
317-
-
316+
- Removed the previously deprecated ``TimeGrouper`` (:issue:`16942`)
317+
- Removed the previously deprecated ``parse_cols`` keyword in :func:`read_excel` (:issue:`16488`)
318318

319319
.. _whatsnew_0250.performance:
320320

pandas/io/excel/_base.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@
6464
those columns will be combined into a ``MultiIndex``. If a
6565
subset of data is selected with ``usecols``, index_col
6666
is based on the subset.
67-
parse_cols : int or list, default None
68-
Alias of `usecols`.
69-
70-
.. deprecated:: 0.21.0
71-
Use `usecols` instead.
72-
7367
usecols : int, str, list-like, or callable default None
7468
Return a subset of the columns.
7569
@@ -260,14 +254,12 @@
260254

261255

262256
@Appender(_read_excel_doc)
263-
@deprecate_kwarg("parse_cols", "usecols")
264257
@deprecate_kwarg("skip_footer", "skipfooter")
265258
def read_excel(io,
266259
sheet_name=0,
267260
header=0,
268261
names=None,
269262
index_col=None,
270-
parse_cols=None,
271263
usecols=None,
272264
squeeze=False,
273265
dtype=None,
@@ -290,7 +282,7 @@ def read_excel(io,
290282
mangle_dupe_cols=True,
291283
**kwds):
292284

293-
for arg in ('sheet', 'sheetname'):
285+
for arg in ('sheet', 'sheetname', 'parse_cols'):
294286
if arg in kwds:
295287
raise TypeError("read_excel() got an unexpected keyword argument "
296288
"`{}`".format(arg))

pandas/tests/io/test_excel.py

+1-21
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,9 @@ def test_usecols_int(self, ext):
147147
df2 = self.get_exceldf("test1", ext, "Sheet2", skiprows=[1],
148148
index_col=0, usecols=3)
149149

150-
# parse_cols instead of usecols, usecols as int
151-
with tm.assert_produces_warning(FutureWarning,
152-
check_stacklevel=False):
153-
with ignore_xlrd_time_clock_warning():
154-
df3 = self.get_exceldf("test1", ext, "Sheet2", skiprows=[1],
155-
index_col=0, parse_cols=3)
156-
157150
# TODO add index to xls file)
158151
tm.assert_frame_equal(df1, df_ref, check_names=False)
159152
tm.assert_frame_equal(df2, df_ref, check_names=False)
160-
tm.assert_frame_equal(df3, df_ref, check_names=False)
161153

162154
@td.skip_if_no('xlrd', '1.0.1') # GH-22682
163155
def test_usecols_list(self, ext):
@@ -169,15 +161,9 @@ def test_usecols_list(self, ext):
169161
df2 = self.get_exceldf('test1', ext, 'Sheet2', skiprows=[1],
170162
index_col=0, usecols=[0, 2, 3])
171163

172-
with tm.assert_produces_warning(FutureWarning):
173-
with ignore_xlrd_time_clock_warning():
174-
df3 = self.get_exceldf('test1', ext, 'Sheet2', skiprows=[1],
175-
index_col=0, parse_cols=[0, 2, 3])
176-
177164
# TODO add index to xls file)
178165
tm.assert_frame_equal(df1, dfref, check_names=False)
179166
tm.assert_frame_equal(df2, dfref, check_names=False)
180-
tm.assert_frame_equal(df3, dfref, check_names=False)
181167

182168
@td.skip_if_no('xlrd', '1.0.1') # GH-22682
183169
def test_usecols_str(self, ext):
@@ -190,15 +176,9 @@ def test_usecols_str(self, ext):
190176
df3 = self.get_exceldf('test1', ext, 'Sheet2', skiprows=[1],
191177
index_col=0, usecols='A:D')
192178

193-
with tm.assert_produces_warning(FutureWarning):
194-
with ignore_xlrd_time_clock_warning():
195-
df4 = self.get_exceldf('test1', ext, 'Sheet2', skiprows=[1],
196-
index_col=0, parse_cols='A:D')
197-
198179
# TODO add index to xls, read xls ignores index name ?
199180
tm.assert_frame_equal(df2, df1, check_names=False)
200181
tm.assert_frame_equal(df3, df1, check_names=False)
201-
tm.assert_frame_equal(df4, df1, check_names=False)
202182

203183
df1 = dfref.reindex(columns=['B', 'C'])
204184
df2 = self.get_exceldf('test1', ext, 'Sheet1', index_col=0,
@@ -342,7 +322,7 @@ def test_excel_passes_na(self, ext):
342322
tm.assert_frame_equal(parsed, expected)
343323

344324
@td.skip_if_no('xlrd', '1.0.1') # GH-22682
345-
@pytest.mark.parametrize('arg', ['sheet', 'sheetname'])
325+
@pytest.mark.parametrize('arg', ['sheet', 'sheetname', 'parse_cols'])
346326
def test_unexpected_kwargs_raises(self, ext, arg):
347327
# gh-17964
348328
excel = self.get_excelfile('test1', ext)

0 commit comments

Comments
 (0)