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.
Syntax:
DataFrame.memory_usage(self, index=True, deep=False)
Parameters:
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 |
Required |
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 |
Required |
Returns: Series
A Series whose index is the original column names and whose values is the memory usage of each column in bytes.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - shape property
Next: DataFrame - empty property
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/dataframe/dataframe-memory_usage.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics