pick number pandas catogery code example
Example 1: using df.astype to select categorical data and numerical data
df = pd.DataFrame({'vertebrates': ['Bird', 'Bird', 'Mammal', 'Fish', 'Amphibian', 'Reptile', 'Mammal']})
df.vertebrates.astype("category").cat.codes
Example 2: treat NaN as a category
g_without_nan = g.cat.add_categories("D").fillna("D")