Pandas DataFrame: memory_usage() function

DataFrame - memory_usage() function

The memory_usage function is used to get the memory usage of each column in bytes.

The memory usage can optionally include the contribution of the index and elements of object dtype.

This value is displayed in DataFrame.info by default. This can be suppressed by setting pandas.options.display.memory_usage to False.


DataFrame.memory_usage(self, index=True, deep=False)


Name Description Type/Default Value Required / Optional
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 is the first item in the output. bool
Default Value: True
deep  If True, introspect the data deeply by interrogating object dtypes for system-level memory consumption, and include it in the returned values. bool
Default Value: False

Returns: Series
A Series whose index is the original column names and whose values is the memory usage of each column in bytes.


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - shape property
Next: DataFrame - empty property

Share this Tutorial / Exercise on : Facebook and Twitter