Skip to content

Commit 006bd0b

Browse files
gfyoungjreback
authored andcommitted
CLN: removed setter method of categorical's ordered attribute
xref #9611 Author: gfyoung <[email protected]> Closes #13671 from gfyoung/cat-set-order-removal and squashes the following commits: 58938e7 [gfyoung] CLN: removed setter method of categorical's ordered attribute
1 parent 1e1e9b3 commit 006bd0b

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

doc/source/whatsnew/v0.19.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ Removal of prior version deprecations/changes
508508
- The ``pd.sandbox`` module has been removed in favor of the external library ``pandas-qt`` (:issue:`13670`)
509509
- ``DataFrame.to_csv()`` has dropped the ``engine`` parameter, as was deprecated in 0.17.1 (:issue:`11274`, :issue:`13419`)
510510
- ``DataFrame.to_dict()`` has dropped the ``outtype`` parameter in favor of ``orient`` (:issue:`13627`, :issue:`8486`)
511+
- ``pd.Categorical`` has dropped setting of the ``ordered`` attribute directly in favor of the ``set_ordered`` method (:issue:`13671`)
511512
- ``pd.Categorical`` has dropped the ``levels`` attribute in favour of ``categories`` (:issue:`8376`)
512513

513514
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`)

pandas/core/categorical.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,6 @@ def _get_categories(self):
571571

572572
_ordered = None
573573

574-
def _set_ordered(self, value):
575-
""" Sets the ordered attribute to the boolean value """
576-
warn("Setting 'ordered' directly is deprecated, use 'set_ordered'",
577-
FutureWarning, stacklevel=2)
578-
self.set_ordered(value, inplace=True)
579-
580574
def set_ordered(self, value, inplace=False):
581575
"""
582576
Sets the ordered attribute to the boolean value
@@ -624,7 +618,7 @@ def _get_ordered(self):
624618
""" Gets the ordered attribute """
625619
return self._ordered
626620

627-
ordered = property(fget=_get_ordered, fset=_set_ordered)
621+
ordered = property(fget=_get_ordered)
628622

629623
def set_categories(self, new_categories, ordered=None, rename=False,
630624
inplace=False):

pandas/tests/test_categorical.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,12 @@ def test_set_ordered(self):
808808
cat2.set_ordered(False, inplace=True)
809809
self.assertFalse(cat2.ordered)
810810

811-
# deperecated in v0.16.0
812-
with tm.assert_produces_warning(FutureWarning):
813-
cat.ordered = False
814-
self.assertFalse(cat.ordered)
815-
with tm.assert_produces_warning(FutureWarning):
811+
# removed in 0.19.0
812+
msg = "can\'t set attribute"
813+
with tm.assertRaisesRegexp(AttributeError, msg):
816814
cat.ordered = True
817-
self.assertTrue(cat.ordered)
815+
with tm.assertRaisesRegexp(AttributeError, msg):
816+
cat.ordered = False
818817

819818
def test_set_categories(self):
820819
cat = Categorical(["a", "b", "c", "a"], ordered=True)

0 commit comments

Comments
 (0)