plydata.cat_tools.cat_relevel¶
-
plydata.cat_tools.
cat_relevel
(c, *args, to=0)¶ Reorder categories explicitly
- Parameters
- Returns
- out
categorical
Values
- out
Examples
>>> c = ['a', 'b', 'c', 'd', 'e'] >>> cat_move(c, 'e', 'b') ['a', 'b', 'c', 'd', 'e'] Categories (5, object): ['e', 'b', 'a', 'c', 'd'] >>> cat_move(c, 'c', to=np.inf) ['a', 'b', 'c', 'd', 'e'] Categories (5, object): ['a', 'b', 'd', 'e', 'c'] >>> cat_move(pd.Categorical(c, ordered=True), 'a', 'c', 'e', to=1) ['a', 'b', 'c', 'd', 'e'] Categories (5, object): ['b' < 'a' < 'c' < 'e' < 'd']