Skip to content

Instantly share code, notes, and snippets.

@YiLi225
Last active September 9, 2020 03:12
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/b5fd23fd3ebea8d20b380fffdd62c57e to your computer and use it in GitHub Desktop.
Save YiLi225/b5fd23fd3ebea8d20b380fffdd62c57e to your computer and use it in GitHub Desktop.
## Correct way to set new category values ##
dairy_table['Food_Category'] = dairy_table['Food_Category'].cat.add_categories(['Another_Category'])
dairy_table['Food_Category'].iloc[2] = 'Another_Category'
Out[116]:
index0 Milk
index1 others
index2 Another_Category
index3 Milk
index4 Milk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment