Python是进行数据分析的一种出色语言,主要是因为以数据为中心的python软件包具有奇妙的生态系统。 Pandas是其中的一种,使导入和分析数据更加容易。
Pandas Index.memory_usage()函数返回索引的内存使用情况。它返回索引中存在的所有单个标签所使用的内存总和。
用法: Index.memory_usage(deep=False)
参数:
deep:深入反思数据,询问对象dtype以获取系统级内存消耗
返回:使用的字节
范例1:采用Index.memory_usage()函数查找Index对象使用的总内存。
# importing pandas as pd
import pandas as pd
# Creating the Index
idx = pd.Index(['Labrador', 'Beagle', 'Mastiff', 'Lhasa', 'Husky', 'Beagle'])
# Print the Index
idx
输出:
现在我们将使用Index.memory_usage()函数查找idx对象的内存使用情况。
# finding the memory used by the idx object
idx.memory_usage()
输出:
该函数返回的值48表示正在使用48个字节的内存。
范例2:采用Index.