Working with Categories in Pandas

In this lesson, we will understand how to work with Categories in Pandas. We will learn the following with examples:

  • Append new categories
  • Remove a category

Append new categories

To append new categories, use the add_categories() method in Python Pandas. Let us see an example:

Output

Remove a Category in Pandas

To remove a category, use the remove_categories() method in Python Pandas. Let us see an example:

Output

As you can see above, now we have 3 categories, since we have removed one of the categories.

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others:


For Videos, Join Our YouTube Channel: Join Now


Read More:

Categorical Data in Pandas
Pandas - Plotting
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading