Categorical Data

https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html

Object Creation

Series Creation

Categorical Series or columns in a DataFrame can be created in several ways:

By specifying dtype="category" when constructing a Series:

In [1]: s = pd.Series(["a", "b", "c", "a"], dtype="category")

In [2]: s
Out[2]: 
0    a
1    b
2    c
3    a
dtype: category
Categories (3, object): [a, b, c]
posted on 2019-02-26 14:39  guolongnv  阅读(123)  评论(0)    收藏  举报