The Pandas function
dataframe.memory_usage() returns the memory usage of each column in bytes. Memory usage can optionally include the contribution of the index and the elements of the dtype object. This value is displayed in DataFrame.info by default.
Syntax: DataFrame.memory_usage (index = True, deep = False)
index: Specifies whether to include the memory usage of the DataFrame’s index in returned Series. If index = True the memory usage of the index the first item in the output.
deep: If True, introspect the data deeply by interrogating object dtypes for system-level memory consumption, and include it in the returned values.
Returns: A Series whose index is the original column names and whose values is the memory usage of each column in bytes
To link to the CSV file used in the code, click here
Example # 1: Using the
memory_usage () function prints memory usage information for each column in the data frame, along with index usage.
memory_usage () to find the memory usage for each column.
Example # 2: Use
memory_usage () to find the memory usage of each column, but not index.