DataFrame.memory_usage(index=True, deep=False)[source]
返回每列的内存使用情况(以字节为单位)。
内存使用情况可以选择包括索引和对象 dtype元素的贡献。
默认情况下,此值显示在DataFrame.info中。可以通过设置pandas.options.display.memory_usage=False 来取消这种情况。
参数:index: bool,默认为True
指定是否在返回的Series中包括DataFrame索引的内存使用情况。
如果index=True索引的内存使用率在输出中的第一项。
deep : bool,默认为False
如果为True,则通过询问对象 dtype
来深入了解数据 的系统级内存消耗,
并将其包含在返回值中。
返回值:sizes : Series
一个Series,其索引是原始列名,
其值是每列的内存使用量(以字节为单位)。
例子>>> dtypes = ['int64', 'float64', 'complex128', 'object', 'bool']
>>> data = dict([(t, np.ones(shape=5000).astype(t))
... for t in dtypes])
>>> df = pd.DataFrame(data)
>>> df.head()
int64