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: Remove deprecated parse_cols from read_excel #26522

Merged
merged 1 commit into from
May 25, 2019
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: 2 additions & 2 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ Removal of prior version deprecations/changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Removed ``Panel`` (:issue:`25047`, :issue:`25191`, :issue:`25231`)
- Removed the previously deprecated ``sheetname`` keyword in :func:`read_excel` (:issue:`16442`, :issue:`20938`)
- Removed previously deprecated ``TimeGrouper`` (:issue:`16942`)
-
- Removed the previously deprecated ``TimeGrouper`` (:issue:`16942`)
- Removed the previously deprecated ``parse_cols`` keyword in :func:`read_excel` (:issue:`16488`)

.. _whatsnew_0250.performance:

Expand Down
10 changes: 1 addition & 9 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@
those columns will be combined into a ``MultiIndex``. If a
subset of data is selected with ``usecols``, index_col
is based on the subset.
parse_cols : int or list, default None
Alias of `usecols`.

.. deprecated:: 0.21.0
Use `usecols` instead.

usecols : int, str, list-like, or callable default None
Return a subset of the columns.

Expand Down Expand Up @@ -260,14 +254,12 @@


@Appender(_read_excel_doc)
@deprecate_kwarg("parse_cols", "usecols")
@deprecate_kwarg("skip_footer", "skipfooter")
def read_excel(io,
sheet_name=0,
header=0,
names=None,
index_col=None,
parse_cols=None,
usecols=None,
squeeze=False,
dtype=None,
Expand All @@ -290,7 +282,7 @@ def read_excel(io,
mangle_dupe_cols=True,
**kwds):

for arg in ('sheet', 'sheetname'):
for arg in ('sheet', 'sheetname', 'parse_cols'):
if arg in kwds:
raise TypeError("read_excel() got an unexpected keyword argument "
"`{}`".format(arg))
Expand Down
22 changes: 1 addition & 21 deletions pandas/tests/io/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,9 @@ def test_usecols_int(self, ext):
df2 = self.get_exceldf("test1", ext, "Sheet2", skiprows=[1],
index_col=0, usecols=3)

# parse_cols instead of usecols, usecols as int
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
with ignore_xlrd_time_clock_warning():
df3 = self.get_exceldf("test1", ext, "Sheet2", skiprows=[1],
index_col=0, parse_cols=3)

# TODO add index to xls file)
tm.assert_frame_equal(df1, df_ref, check_names=False)
tm.assert_frame_equal(df2, df_ref, check_names=False)
tm.assert_frame_equal(df3, df_ref, check_names=False)

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

with tm.assert_produces_warning(FutureWarning):
with ignore_xlrd_time_clock_warning():
df3 = self.get_exceldf('test1', ext, 'Sheet2', skiprows=[1],
index_col=0, parse_cols=[0, 2, 3])

# TODO add index to xls file)
tm.assert_frame_equal(df1, dfref, check_names=False)
tm.assert_frame_equal(df2, dfref, check_names=False)
tm.assert_frame_equal(df3, dfref, check_names=False)

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

with tm.assert_produces_warning(FutureWarning):
with ignore_xlrd_time_clock_warning():
df4 = self.get_exceldf('test1', ext, 'Sheet2', skiprows=[1],
index_col=0, parse_cols='A:D')

# TODO add index to xls, read xls ignores index name ?
tm.assert_frame_equal(df2, df1, check_names=False)
tm.assert_frame_equal(df3, df1, check_names=False)
tm.assert_frame_equal(df4, df1, check_names=False)

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

@td.skip_if_no('xlrd', '1.0.1') # GH-22682
@pytest.mark.parametrize('arg', ['sheet', 'sheetname'])
@pytest.mark.parametrize('arg', ['sheet', 'sheetname', 'parse_cols'])
def test_unexpected_kwargs_raises(self, ext, arg):
# gh-17964
excel = self.get_excelfile('test1', ext)
Expand Down