From e6b8459ecbc6f80de2abf7c891c13be4c7da3a78 Mon Sep 17 00:00:00 2001 From: Terji Petersen Date: Sun, 23 Oct 2022 03:03:28 +0100 Subject: [PATCH 1/4] DEPR: drop setting categorical codes --- pandas/core/arrays/categorical.py | 10 ---------- pandas/tests/arrays/categorical/test_api.py | 9 --------- 2 files changed, 19 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 48371b7f14b28..15a7c8d52b724 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -2059,16 +2059,6 @@ def _values_for_rank(self): def _codes(self) -> np.ndarray: return self._ndarray - @_codes.setter - def _codes(self, value: np.ndarray) -> None: - warn( - "Setting the codes on a Categorical is deprecated and will raise in " - "a future version. Create a new Categorical object instead", - FutureWarning, - stacklevel=find_stack_level(), - ) # GH#40606 - NDArrayBacked.__init__(self, value, self.dtype) - def _box_func(self, i: int): if i == -1: return np.NaN diff --git a/pandas/tests/arrays/categorical/test_api.py b/pandas/tests/arrays/categorical/test_api.py index e3fd73aaa9b1c..03bd1c522838d 100644 --- a/pandas/tests/arrays/categorical/test_api.py +++ b/pandas/tests/arrays/categorical/test_api.py @@ -516,15 +516,6 @@ def test_set_categories_inplace(self, factor): tm.assert_index_equal(cat.categories, Index(["a", "b", "c", "d"])) - def test_codes_setter_deprecated(self): - cat = Categorical([1, 2, 3, 1, 2, 3, 3, 2, 1, 1, 1]) - new_codes = cat._codes + 1 - with tm.assert_produces_warning(FutureWarning): - # GH#40606 - cat._codes = new_codes - - assert cat._codes is new_codes - class TestPrivateCategoricalAPI: def test_codes_immutable(self): From 27de8c9186cecf57a136590491089d18bc3fdf32 Mon Sep 17 00:00:00 2001 From: Terji Petersen Date: Sun, 23 Oct 2022 03:09:40 +0100 Subject: [PATCH 2/4] add gh-number --- doc/source/whatsnew/v2.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 0880b8e2cac12..7af62a989be3a 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -198,6 +198,7 @@ Removal of prior version deprecations/changes - Removed ``pandas.SparseArray`` in favor of :class:`arrays.SparseArray` (:issue:`30642`) - Removed ``pandas.SparseSeries`` and ``pandas.SparseDataFrame`` (:issue:`30642`) - Enforced disallowing a string column label into ``times`` in :meth:`DataFrame.ewm` (:issue:`43265`) +- Removed setting Categorical._codes directly (:issues:`49258`) - Enforced :meth:`Rolling.count` with ``min_periods=None`` to default to the size of the window (:issue:`31302`) - From 19fb91eb01eaedfb4cf2a5546b2a58c5ea3bf798 Mon Sep 17 00:00:00 2001 From: Terji Petersen Date: Sun, 23 Oct 2022 03:10:50 +0100 Subject: [PATCH 3/4] add gh-number --- doc/source/whatsnew/v2.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 7af62a989be3a..b1f7f790d9f12 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -198,7 +198,7 @@ Removal of prior version deprecations/changes - Removed ``pandas.SparseArray`` in favor of :class:`arrays.SparseArray` (:issue:`30642`) - Removed ``pandas.SparseSeries`` and ``pandas.SparseDataFrame`` (:issue:`30642`) - Enforced disallowing a string column label into ``times`` in :meth:`DataFrame.ewm` (:issue:`43265`) -- Removed setting Categorical._codes directly (:issues:`49258`) +- Removed setting Categorical._codes directly (:issues:`41429`) - Enforced :meth:`Rolling.count` with ``min_periods=None`` to default to the size of the window (:issue:`31302`) - From 7bcb0053cfb4bce2399092e0520dc5bb111ced51 Mon Sep 17 00:00:00 2001 From: Terji Petersen Date: Sun, 23 Oct 2022 09:08:35 +0100 Subject: [PATCH 4/4] fix gh-number --- doc/source/whatsnew/v2.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index b1f7f790d9f12..0d6660b4a27f1 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -198,7 +198,7 @@ Removal of prior version deprecations/changes - Removed ``pandas.SparseArray`` in favor of :class:`arrays.SparseArray` (:issue:`30642`) - Removed ``pandas.SparseSeries`` and ``pandas.SparseDataFrame`` (:issue:`30642`) - Enforced disallowing a string column label into ``times`` in :meth:`DataFrame.ewm` (:issue:`43265`) -- Removed setting Categorical._codes directly (:issues:`41429`) +- Removed setting Categorical._codes directly (:issue:`41429`) - Enforced :meth:`Rolling.count` with ``min_periods=None`` to default to the size of the window (:issue:`31302`) -