Skip to content

DEPR: remove deprecated keywords in read_excel, to_records #29721

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

Merged
merged 2 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- Removed the previously deprecated ``assert_raises_regex`` function in ``pandas.util.testing`` (:issue:`29174`)
- Removed :meth:`Index.is_lexsorted_for_tuple` (:issue:`29305`)
- Removed support for nexted renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`29608`)
-
- :func:`read_excel` removed support for "skip_footer" argument, use "skipfooter" instead (:issue:`18836`)
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)

.. _whatsnew_1000.performance:

Expand Down
30 changes: 5 additions & 25 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
ensure_platform_int,
infer_dtype_from_object,
is_bool_dtype,
is_datetime64_any_dtype,
is_dict_like,
is_dtype_equal,
is_extension_array_dtype,
Expand Down Expand Up @@ -1685,9 +1684,7 @@ def from_records(

return cls(mgr)

def to_records(
self, index=True, convert_datetime64=None, column_dtypes=None, index_dtypes=None
):
def to_records(self, index=True, column_dtypes=None, index_dtypes=None):
"""
Convert DataFrame to a NumPy record array.

Expand All @@ -1699,11 +1696,6 @@ def to_records(
index : bool, default True
Include index in resulting record array, stored in 'index'
field or using the index label, if set.
convert_datetime64 : bool, default None
.. deprecated:: 0.23.0

Whether to convert the index to datetime.datetime if it is a
DatetimeIndex.
column_dtypes : str, type, dict, default None
.. versionadded:: 0.24.0

Expand Down Expand Up @@ -1778,24 +1770,12 @@ def to_records(
dtype=[('I', 'S1'), ('A', '<i8'), ('B', '<f8')])
"""

if convert_datetime64 is not None:
warnings.warn(
"The 'convert_datetime64' parameter is "
"deprecated and will be removed in a future "
"version",
FutureWarning,
stacklevel=2,
)

if index:
if is_datetime64_any_dtype(self.index) and convert_datetime64:
ix_vals = [self.index.to_pydatetime()]
if isinstance(self.index, ABCMultiIndex):
# array of tuples to numpy cols. copy copy copy
ix_vals = list(map(np.array, zip(*self.index.values)))
else:
if isinstance(self.index, ABCMultiIndex):
# array of tuples to numpy cols. copy copy copy
ix_vals = list(map(np.array, zip(*self.index.values)))
else:
ix_vals = [self.index.values]
ix_vals = [self.index.values]

arrays = ix_vals + [self[c]._internal_get_values() for c in self.columns]

Expand Down
9 changes: 1 addition & 8 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pandas._config import config

from pandas.errors import EmptyDataError
from pandas.util._decorators import Appender, deprecate_kwarg
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import is_bool, is_float, is_integer, is_list_like

Expand Down Expand Up @@ -188,11 +188,6 @@
Comments out remainder of line. Pass a character or characters to this
argument to indicate comments in the input file. Any data between the
comment string and the end of the current line is ignored.
skip_footer : int, default 0
Alias of `skipfooter`.

.. deprecated:: 0.23.0
Use `skipfooter` instead.
skipfooter : int, default 0
Rows at the end to skip (0-indexed).
convert_float : bool, default True
Expand Down Expand Up @@ -277,7 +272,6 @@


@Appender(_read_excel_doc)
@deprecate_kwarg("skip_footer", "skipfooter")
def read_excel(
io,
sheet_name=0,
Expand All @@ -300,7 +294,6 @@ def read_excel(
date_parser=None,
thousands=None,
comment=None,
skip_footer=0,
skipfooter=0,
convert_float=True,
mangle_dupe_cols=True,
Expand Down
13 changes: 0 additions & 13 deletions pandas/tests/frame/test_convert_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,10 @@ def test_to_records_dt64(self):
index=date_range("2012-01-01", "2012-01-02"),
)

# convert_datetime64 defaults to None
expected = df.index.values[0]
result = df.to_records()["index"][0]
assert expected == result

# check for FutureWarning if convert_datetime64=False is passed
with tm.assert_produces_warning(FutureWarning):
expected = df.index.values[0]
result = df.to_records(convert_datetime64=False)["index"][0]
assert expected == result

# check for FutureWarning if convert_datetime64=True is passed
with tm.assert_produces_warning(FutureWarning):
expected = df.index[0]
result = df.to_records(convert_datetime64=True)["index"][0]
assert expected == result

def test_to_records_with_multindex(self):
# GH3189
index = [
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,14 +917,6 @@ def test_excel_table_sheet_by_index(self, read_ext, df_ref):
df3 = pd.read_excel(excel, 0, index_col=0, skipfooter=1)
tm.assert_frame_equal(df3, df1.iloc[:-1])

with tm.assert_produces_warning(
FutureWarning, check_stacklevel=False, raise_on_extra_warnings=False
):
with pd.ExcelFile("test1" + read_ext) as excel:
df4 = pd.read_excel(excel, 0, index_col=0, skip_footer=1)

tm.assert_frame_equal(df3, df4)

with pd.ExcelFile("test1" + read_ext) as excel:
df3 = excel.parse(0, index_col=0, skipfooter=1)

Expand Down