Categorical Data in Python
From the Pandas cheat sheet ยท Text and Categories ยท verified Aug 2026
Categorical Data
Represent repeated finite labels efficiently.
python
df["size"] = df["size"].astype("category")๐ก Categories reduce memory for repeated labels
๐ Ordered categories support meaningful sorting
โ ๏ธ Add a category before assigning a new label
๐ cat accessor manages category metadata
categorydtypememory
Continue with Pandas
Save the full cheat sheet or work through every related task.