Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: Removing previously deprecated Categorical.labels (#6581) #19120

Merged
merged 2 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`)

.. _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