MCPcopy
hub / github.com/pandas-dev/pandas / set_ordered

Method set_ordered

pandas/core/arrays/categorical.py:994–1006  ·  view source on GitHub ↗

Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False).

(self, value: bool)

Source from the content-addressed store, hash-verified

992 return type(self)._simple_new(codes, dtype=dtype)
993
994 def set_ordered(self, value: bool) -> Self:
995 """
996 Set the ordered attribute to the boolean value.
997
998 Parameters
999 ----------
1000 value : bool
1001 Set whether this categorical is ordered (True) or not (False).
1002 """
1003 new_dtype = CategoricalDtype(self.categories, ordered=value)
1004 cat = self.copy()
1005 NDArrayBacked.__init__(cat, cat._ndarray, new_dtype)
1006 return cat
1007
1008 def as_ordered(self) -> Self:
1009 """

Callers 5

as_orderedMethod · 0.95
as_unorderedMethod · 0.95
test_comparisonsMethod · 0.95
test_set_categoriesMethod · 0.95
test_set_orderedMethod · 0.80

Calls 3

CategoricalDtypeClass · 0.90
copyMethod · 0.45
__init__Method · 0.45

Tested by 3

test_comparisonsMethod · 0.76
test_set_categoriesMethod · 0.76
test_set_orderedMethod · 0.64