Back to search

When should you use categorical dtype in pandas?

Use categorical dtype for repeated low-cardinality labels to save memory and make category semantics explicit.

Pandas Medium Theory

When should you use categorical dtype in pandas?

Use categorical dtype for repeated low-cardinality labels to save memory and make category semantics explicit.

  • Good for repeated labels
  • Smaller than object strings
  • Categories can be ordered

When should you use categorical dtype in pandas?