Categorical()
pandas.Categorical
-
class pandas.Categorical(values, categories=None, ordered=False, name=None, fastpath=False, levels=None)
-
Represents a categorical variable in classic R / S-plus fashion
Categoricals
can only take on only a limited, and usually fixed, number of possible values (categories
). In contrast to statistical categorical variables, aCategorical
might have an order, but numerical operations (additions, divisions, ...) are not possible.All values of the
Categorical
are either incategories
ornp.nan
. Assigning values outside ofcategories
will raise aValueError
. Order is defined by the order of thecategories
, not lexical order of the values.登录查看完整内容