Skip to content

Commit f3e7952

Browse files
jbrockmendelproost
authored andcommitted
DEPR: remove deprecated keywords in read_excel, to_records (pandas-dev#29721)
1 parent 142c8ff commit f3e7952

File tree

5 files changed

+8
-54
lines changed

5 files changed

+8
-54
lines changed

doc/source/whatsnew/v1.0.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
315315
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
316316
- :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`)
317317
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
318+
- :func:`read_excel` removed support for "skip_footer" argument, use "skipfooter" instead (:issue:`18836`)
319+
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)
318320
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
319321
- Changed the default value for the "keep_tz" argument in :meth:`DatetimeIndex.to_series` to ``True`` (:issue:`23739`)
320322
- Ability to read pickles containing :class:`Categorical` instances created with pre-0.16 version of pandas has been removed (:issue:`27538`)

pandas/core/frame.py

+5-25
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
ensure_platform_int,
6767
infer_dtype_from_object,
6868
is_bool_dtype,
69-
is_datetime64_any_dtype,
7069
is_dict_like,
7170
is_dtype_equal,
7271
is_extension_array_dtype,
@@ -1685,9 +1684,7 @@ def from_records(
16851684

16861685
return cls(mgr)
16871686

1688-
def to_records(
1689-
self, index=True, convert_datetime64=None, column_dtypes=None, index_dtypes=None
1690-
):
1687+
def to_records(self, index=True, column_dtypes=None, index_dtypes=None):
16911688
"""
16921689
Convert DataFrame to a NumPy record array.
16931690
@@ -1699,11 +1696,6 @@ def to_records(
16991696
index : bool, default True
17001697
Include index in resulting record array, stored in 'index'
17011698
field or using the index label, if set.
1702-
convert_datetime64 : bool, default None
1703-
.. deprecated:: 0.23.0
1704-
1705-
Whether to convert the index to datetime.datetime if it is a
1706-
DatetimeIndex.
17071699
column_dtypes : str, type, dict, default None
17081700
.. versionadded:: 0.24.0
17091701
@@ -1778,24 +1770,12 @@ def to_records(
17781770
dtype=[('I', 'S1'), ('A', '<i8'), ('B', '<f8')])
17791771
"""
17801772

1781-
if convert_datetime64 is not None:
1782-
warnings.warn(
1783-
"The 'convert_datetime64' parameter is "
1784-
"deprecated and will be removed in a future "
1785-
"version",
1786-
FutureWarning,
1787-
stacklevel=2,
1788-
)
1789-
17901773
if index:
1791-
if is_datetime64_any_dtype(self.index) and convert_datetime64:
1792-
ix_vals = [self.index.to_pydatetime()]
1774+
if isinstance(self.index, ABCMultiIndex):
1775+
# array of tuples to numpy cols. copy copy copy
1776+
ix_vals = list(map(np.array, zip(*self.index.values)))
17931777
else:
1794-
if isinstance(self.index, ABCMultiIndex):
1795-
# array of tuples to numpy cols. copy copy copy
1796-
ix_vals = list(map(np.array, zip(*self.index.values)))
1797-
else:
1798-
ix_vals = [self.index.values]
1778+
ix_vals = [self.index.values]
17991779

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

pandas/io/excel/_base.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pandas._config import config
99

1010
from pandas.errors import EmptyDataError
11-
from pandas.util._decorators import Appender, deprecate_kwarg
11+
from pandas.util._decorators import Appender
1212

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

@@ -188,11 +188,6 @@
188188
Comments out remainder of line. Pass a character or characters to this
189189
argument to indicate comments in the input file. Any data between the
190190
comment string and the end of the current line is ignored.
191-
skip_footer : int, default 0
192-
Alias of `skipfooter`.
193-
194-
.. deprecated:: 0.23.0
195-
Use `skipfooter` instead.
196191
skipfooter : int, default 0
197192
Rows at the end to skip (0-indexed).
198193
convert_float : bool, default True
@@ -277,7 +272,6 @@
277272

278273

279274
@Appender(_read_excel_doc)
280-
@deprecate_kwarg("skip_footer", "skipfooter")
281275
def read_excel(
282276
io,
283277
sheet_name=0,
@@ -300,7 +294,6 @@ def read_excel(
300294
date_parser=None,
301295
thousands=None,
302296
comment=None,
303-
skip_footer=0,
304297
skipfooter=0,
305298
convert_float=True,
306299
mangle_dupe_cols=True,

pandas/tests/frame/test_convert_to.py

-13
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,10 @@ def test_to_records_dt64(self):
8383
index=date_range("2012-01-01", "2012-01-02"),
8484
)
8585

86-
# convert_datetime64 defaults to None
8786
expected = df.index.values[0]
8887
result = df.to_records()["index"][0]
8988
assert expected == result
9089

91-
# check for FutureWarning if convert_datetime64=False is passed
92-
with tm.assert_produces_warning(FutureWarning):
93-
expected = df.index.values[0]
94-
result = df.to_records(convert_datetime64=False)["index"][0]
95-
assert expected == result
96-
97-
# check for FutureWarning if convert_datetime64=True is passed
98-
with tm.assert_produces_warning(FutureWarning):
99-
expected = df.index[0]
100-
result = df.to_records(convert_datetime64=True)["index"][0]
101-
assert expected == result
102-
10390
def test_to_records_with_multindex(self):
10491
# GH3189
10592
index = [

pandas/tests/io/excel/test_readers.py

-8
Original file line numberDiff line numberDiff line change
@@ -917,14 +917,6 @@ def test_excel_table_sheet_by_index(self, read_ext, df_ref):
917917
df3 = pd.read_excel(excel, 0, index_col=0, skipfooter=1)
918918
tm.assert_frame_equal(df3, df1.iloc[:-1])
919919

920-
with tm.assert_produces_warning(
921-
FutureWarning, check_stacklevel=False, raise_on_extra_warnings=False
922-
):
923-
with pd.ExcelFile("test1" + read_ext) as excel:
924-
df4 = pd.read_excel(excel, 0, index_col=0, skip_footer=1)
925-
926-
tm.assert_frame_equal(df3, df4)
927-
928920
with pd.ExcelFile("test1" + read_ext) as excel:
929921
df3 = excel.parse(0, index_col=0, skipfooter=1)
930922

0 commit comments

Comments
 (0)