Ben Chuanlong Du's Blog

It is never too late to learn.

Categorical Data in Pandas

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

In [1]:
import pandas as pd
In [4]:
s = pd.Series([1, 2, 3, 3, 2, 1], dtype="category")
s
Out[4]:
0    1
1    2
2    3
3    3
4    2
5    1
dtype: category
Categories (3, int64): [1, 2, 3]
In [5]:
s.sort_values()
Out[5]:
0    1
5    1
1    2
4    2
2    3
3    3
dtype: category
Categories (3, int64): [1, 2, 3]
In [ ]:
 

Comments