Skip to content

Instantly share code, notes, and snippets.

@YiLi225
Created September 7, 2020 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YiLi225/a9b26e049a86562464da820a6ecd6ed1 to your computer and use it in GitHub Desktop.
Save YiLi225/a9b26e049a86562464da820a6ecd6ed1 to your computer and use it in GitHub Desktop.
## Caveat: (1) less flexible regarding assigning new values
dairy_table['Food_Category'] = dairy_table['Food_Category'].astype('category')
dairy_table['Food_Category'].iloc[2] = 'Another_Category'
In [112]: ValueError: Cannot setitem on a Categorical with a new category, set the categories first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment