Reduce pd.DataFrame’s Memory

If you want to reduce the memory of your pandas DataFrame, start with changing the data type of a column. If your categorical variable has low cardinality, change the data type to category like below.

The memory is now is reduced to almost a fifth of what it was!

Scroll to Top