Pandas memory usage: Why you need deep=True for text columns

Pandas memory usage: Why you need deep=True for text columns

How much memory does a text column in your Python Pandas data frame use? Check:

df['x'].memory_usage()

But this is likely a huge underestimate! It sums the pointer sizes, not the string sizes.

Instead, say:

df['x'].memory_usage(deep=True)

Or:

df.info(memory_usage='deep')