Skip to content

Commit

Permalink
DEPR: Removing previously deprecated Categorical.labels (pandas-dev#6581
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista authored and maxim veksler committed Jan 11, 2018
1 parent 4ccc4c6 commit 0b70c2c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 22 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ Removal of prior version deprecations/changes
- The ``Panel4D`` and ``PanelND`` classes have been removed (:issue:`13776`)
- The ``Panel``class has dropped the ``to_long``and ``toLong`` methods (:issue:`19077`)
- The options ``display.line_with`` and ``display.height`` are removed in favor of ``display.width`` and ``display.max_rows`` respectively (:issue:`4391`, :issue:`19107`)
- The ``labels`` attribute of the ``Categorical`` class has been removed in favor of :attribute:`Categorical.codes` (:issue:`7768`)
- The ``flavor`` parameter have been removed from func:`to_sql` method (:issue:`13611`)

.. _whatsnew_0230.performance:
Expand Down
13 changes: 0 additions & 13 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,19 +590,6 @@ def _set_codes(self, codes):

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

def _get_labels(self):
"""
Get the category labels (deprecated).
.. deprecated:: 0.15.0
Use `.codes()` instead.
"""
warn("'labels' is deprecated. Use 'codes' instead", FutureWarning,
stacklevel=2)
return self.codes

labels = property(fget=_get_labels, fset=_set_codes)

def _set_categories(self, categories, fastpath=False):
""" Sets new categories inplace
Expand Down
9 changes: 0 additions & 9 deletions pandas/tests/categorical/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,6 @@ def test_remove_unused_categories(self):
out = cat.remove_unused_categories()
assert out.get_values().tolist() == val.tolist()

def test_deprecated_labels(self):
# TODO: labels is deprecated and should be removed in 0.18 or 2017,
# whatever is earlier
cat = Categorical([1, 2, 3, np.nan], categories=[1, 2, 3])
exp = cat.codes
with tm.assert_produces_warning(FutureWarning):
res = cat.labels
tm.assert_numpy_array_equal(res, exp)


class TestCategoricalAPIWithFactor(TestCategorical):

Expand Down

0 comments on commit 0b70c2c

Please sign in to comment.