Skip to content

Commit

Permalink
DEPR: remove deprecated keywords in read_excel, to_records (pandas-de…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and proost committed Dec 19, 2019
1 parent 2bec505 commit 732e70b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 54 deletions.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
- :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`)
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
- :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`)
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
- Changed the default value for the "keep_tz" argument in :meth:`DatetimeIndex.to_series` to ``True`` (:issue:`23739`)
- Ability to read pickles containing :class:`Categorical` instances created with pre-0.16 version of pandas has been removed (:issue:`27538`)
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

0 comments on commit 732e70b

Please sign in to comment.