Pandas gives very strange memory estimates. It can't be that a column with lists of 2 numbers, takes almost the same memory as a column with 100 numbers. Numpy's nbytes makes more sense (see example below), but doesn't the memory_usage with deep=True knows how to deal with it?
import pandas as pd
import numpy as np
n_rows = 100000
vecs_1x2 = np.random.random((n_rows, 2))
mats_10x10 = np.random.random((n_rows, 10, 10))
df = pd.DataFrame({'vecs_1x2': list(vecs_1x2), 'mats_10x10': list(mats_10x10)})
print('numpy - vecs_1x2.nbytes: {} Mb'.format(vecs_1x2.nbytes / 1024.**2))
print('numpy - mats_10x10.nbytes: {} Mb'.format(mats_10x10.nbytes / 1024.**2))
print('pandas - df.memory_usage (in Mb):\n{}'.format(df.memory_usage(deep=True, index=False) / 1024.**2))
Outputs:
numpy - vecs_1x2.nbytes: 1.52587890625 Mb
numpy - mats_10x10.nbytes: 76.2939453125 Mb
pandas - df.memory_usage (in Mb):
mats_10x10 11.444092
vecs_1x2 9.918213
How?!