plydata.cat_tools.cat_shuffle¶
-
plydata.cat_tools.
cat_shuffle
(c, random_state=None)[source]¶ Reverse order of categories
- Parameters
- clist-like
Values that will make up the categorical.
- random_state
int
orRandomState
, optional Seed or Random number generator to use. If
None
, then numpy global generatornumpy.random
is used.
- Returns
- out
categorical
Values
- out
Examples
>>> np.random.seed(123) >>> c = ['a', 'b', 'c', 'd', 'e'] >>> cat_shuffle(c) ['a', 'b', 'c', 'd', 'e'] Categories (5, object): ['b', 'd', 'e', 'a', 'c'] >>> cat_shuffle(pd.Categorical(c, ordered=True), 321) ['a', 'b', 'c', 'd', 'e'] Categories (5, object): ['d' < 'b' < 'a' < 'c' < 'e']