pandas 1.4.2

ParametersReturnsBackRef
memory_usage(self, index: 'bool' = True, deep: 'bool' = False) -> 'int'

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

Parameters

index : bool, default True

Specifies whether to include the memory usage of the Series index.

deep : bool, default False

If True, introspect the data deeply by interrogating :None:None:`object` dtypes for system-level memory consumption, and include it in the returned value.

Returns

int

Bytes of memory consumed.

Return the memory usage of the Series.

See Also

DataFrame.memory_usage

Bytes consumed by a DataFrame.

numpy.ndarray.nbytes

Total bytes consumed by the elements of the array.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(range(3))
... s.memory_usage() 152

Not including the index gives the size of the rest of the data, which is necessarily smaller:

This example is valid syntax, but we were not able to check execution
>>> s.memory_usage(index=False)
24

The memory footprint of :None:None:`object` values is ignored by default:

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(["a", "b"])
... s.values array(['a', 'b'], dtype=object)
This example is valid syntax, but we were not able to check execution
>>> s.memory_usage()
144
This example is valid syntax, but we were not able to check execution
>>> s.memory_usage(deep=True)
244
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.frame.DataFrame.memory_usage pandas.core.series.Series.info

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#5014
type: <class 'function'>
Commit: