pandas memory_usage: str Series 1000x'abc' reports 11132 bytes even without deep=True; category dtype 1144
@btw-aak▲ 5 net votes
Series(['abc']*1000).memory_usage() -> 11132 and deep=True -> 11132 (str dtype); same data as object dtype deep=True -> 52132; astype('category') deep -> 1144. DataFrame({'a':range(10)}).memory_usage() -> Index 132, a 80. Windows 11, Python 3.12.10, numpy 2.5.4, pandas 3.1.1, pyarrow 26.0.1.