Skip to content

Commit ea2e26a

Browse files
jbrockmendeljorisvandenbossche
authored andcommitted
DEPR: Series.cat.categorical (#29914)
1 parent 20ff599 commit ea2e26a

File tree

3 files changed

+1
-50
lines changed

3 files changed

+1
-50
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
407407
- Removed the previously deprecated "fastpath" keyword from the :class:`Index` constructor (:issue:`23110`)
408408
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
409409
- Changed the the default value of `inplace` in :meth:`DataFrame.set_index` and :meth:`Series.set_axis`. It now defaults to False (:issue:`27600`)
410+
- Removed the previously deprecated :attr:`Series.cat.categorical`, :attr:`Series.cat.index`, :attr:`Series.cat.name` (:issue:`24751`)
410411
- Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`)
411412
- Passing ``datetime64`` data to :class:`TimedeltaIndex` or ``timedelta64`` data to ``DatetimeIndex`` now raises ``TypeError`` (:issue:`23539`, :issue:`23937`)
412413
- A tuple passed to :meth:`DataFrame.groupby` is now exclusively treated as a single key (:issue:`18314`)

pandas/core/arrays/categorical.py

-37
Original file line numberDiff line numberDiff line change
@@ -2583,43 +2583,6 @@ def _delegate_method(self, name, *args, **kwargs):
25832583
if res is not None:
25842584
return Series(res, index=self._index, name=self._name)
25852585

2586-
@property
2587-
def categorical(self):
2588-
# Note: Upon deprecation, `test_tab_completion_with_categorical` will
2589-
# need to be updated. `categorical` will need to be removed from
2590-
# `ok_for_cat`.
2591-
warn(
2592-
"`Series.cat.categorical` has been deprecated. Use the "
2593-
"attributes on 'Series.cat' directly instead.",
2594-
FutureWarning,
2595-
stacklevel=2,
2596-
)
2597-
return self._parent
2598-
2599-
@property
2600-
def name(self):
2601-
# Note: Upon deprecation, `test_tab_completion_with_categorical` will
2602-
# need to be updated. `name` will need to be removed from
2603-
# `ok_for_cat`.
2604-
warn(
2605-
"`Series.cat.name` has been deprecated. Use `Series.name` instead.",
2606-
FutureWarning,
2607-
stacklevel=2,
2608-
)
2609-
return self._name
2610-
2611-
@property
2612-
def index(self):
2613-
# Note: Upon deprecation, `test_tab_completion_with_categorical` will
2614-
# need to be updated. `index` will need to be removed from
2615-
# ok_for_cat`.
2616-
warn(
2617-
"`Series.cat.index` has been deprecated. Use `Series.index` instead.",
2618-
FutureWarning,
2619-
stacklevel=2,
2620-
)
2621-
return self._index
2622-
26232586

26242587
# utility routines
26252588

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
22

3-
import pandas as pd
43
import pandas.util.testing as tm
54

65

@@ -15,15 +14,3 @@ def test_tab_complete_warning(self, ip):
1514
with tm.assert_produces_warning(None):
1615
with provisionalcompleter("ignore"):
1716
list(ip.Completer.completions("c.", 1))
18-
19-
def test_CategoricalAccessor_categorical_deprecation(self):
20-
with tm.assert_produces_warning(FutureWarning):
21-
pd.Series(["a", "b"], dtype="category").cat.categorical
22-
23-
def test_CategoricalAccessor_name_deprecation(self):
24-
with tm.assert_produces_warning(FutureWarning):
25-
pd.Series(["a", "b"], dtype="category").cat.name
26-
27-
def test_CategoricalAccessor_index_deprecation(self):
28-
with tm.assert_produces_warning(FutureWarning):
29-
pd.Series(["a", "b"], dtype="category").cat.index

0 commit comments

Comments
 (0)