Skip to content

Commit 0b70c2c

Browse files
datapythonistamaxim veksler
authored and
maxim veksler
committed
DEPR: Removing previously deprecated Categorical.labels (pandas-dev#6581) (pandas-dev#19120)
1 parent 4ccc4c6 commit 0b70c2c

File tree

3 files changed

+1
-22
lines changed

3 files changed

+1
-22
lines changed

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ Removal of prior version deprecations/changes
314314
- The ``Panel4D`` and ``PanelND`` classes have been removed (:issue:`13776`)
315315
- The ``Panel``class has dropped the ``to_long``and ``toLong`` methods (:issue:`19077`)
316316
- The options ``display.line_with`` and ``display.height`` are removed in favor of ``display.width`` and ``display.max_rows`` respectively (:issue:`4391`, :issue:`19107`)
317+
- The ``labels`` attribute of the ``Categorical`` class has been removed in favor of :attribute:`Categorical.codes` (:issue:`7768`)
317318
- The ``flavor`` parameter have been removed from func:`to_sql` method (:issue:`13611`)
318319

319320
.. _whatsnew_0230.performance:

pandas/core/categorical.py

-13
Original file line numberDiff line numberDiff line change
@@ -590,19 +590,6 @@ def _set_codes(self, codes):
590590

591591
codes = property(fget=_get_codes, fset=_set_codes, doc=_codes_doc)
592592

593-
def _get_labels(self):
594-
"""
595-
Get the category labels (deprecated).
596-
597-
.. deprecated:: 0.15.0
598-
Use `.codes()` instead.
599-
"""
600-
warn("'labels' is deprecated. Use 'codes' instead", FutureWarning,
601-
stacklevel=2)
602-
return self.codes
603-
604-
labels = property(fget=_get_labels, fset=_set_codes)
605-
606593
def _set_categories(self, categories, fastpath=False):
607594
""" Sets new categories inplace
608595

pandas/tests/categorical/test_api.py

-9
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,6 @@ def test_remove_unused_categories(self):
400400
out = cat.remove_unused_categories()
401401
assert out.get_values().tolist() == val.tolist()
402402

403-
def test_deprecated_labels(self):
404-
# TODO: labels is deprecated and should be removed in 0.18 or 2017,
405-
# whatever is earlier
406-
cat = Categorical([1, 2, 3, np.nan], categories=[1, 2, 3])
407-
exp = cat.codes
408-
with tm.assert_produces_warning(FutureWarning):
409-
res = cat.labels
410-
tm.assert_numpy_array_equal(res, exp)
411-
412403

413404
class TestCategoricalAPIWithFactor(TestCategorical):
414405

0 commit comments

Comments
 (0)