@@ -2765,28 +2765,54 @@ def reindex_axis(self, labels, axis=0, **kwargs):
2765
2765
return self .reindex (index = labels , ** kwargs )
2766
2766
2767
2767
def memory_usage (self , index = True , deep = False ):
2768
- """Memory usage of the Series
2768
+ """
2769
+ Return the memory usage of the Series.
2770
+
2771
+ The memory usage can optionally include the contribution of
2772
+ the index and of elements of `object` dtype.
2769
2773
2770
2774
Parameters
2771
2775
----------
2772
- index : bool
2773
- Specifies whether to include memory usage of Series index
2774
- deep : bool
2775
- Introspect the data deeply, interrogate
2776
- `object` dtypes for system-level memory consumption
2776
+ index : bool, default True
2777
+ Specifies whether to include the memory usage of the Series index.
2778
+ deep : bool, default False
2779
+ If True, introspect the data deeply by interrogating
2780
+ `object` dtypes for system-level memory consumption, and include
2781
+ it in the returned value.
2777
2782
2778
2783
Returns
2779
2784
-------
2780
- scalar bytes of memory consumed
2781
-
2782
- Notes
2783
- -----
2784
- Memory usage does not include memory consumed by elements that
2785
- are not components of the array if deep=False
2785
+ int
2786
+ Bytes of memory consumed.
2786
2787
2787
2788
See Also
2788
2789
--------
2789
- numpy.ndarray.nbytes
2790
+ numpy.ndarray.nbytes : Total bytes consumed by the elements of the
2791
+ array.
2792
+ DataFrame.memory_usage : Bytes consumed by a DataFrame.
2793
+
2794
+ Examples
2795
+ --------
2796
+
2797
+ >>> s = pd.Series(range(3))
2798
+ >>> s.memory_usage()
2799
+ 104
2800
+
2801
+ Not including the index gives the size of the rest of the data, which
2802
+ is necessarily smaller:
2803
+
2804
+ >>> s.memory_usage(index=False)
2805
+ 24
2806
+
2807
+ The memory footprint of `object` values is ignored by default:
2808
+
2809
+ >>> s = pd.Series(["a", "b"])
2810
+ >>> s.values
2811
+ array(['a', 'b'], dtype=object)
2812
+ >>> s.memory_usage()
2813
+ 96
2814
+ >>> s.memory_usage(deep=True)
2815
+ 212
2790
2816
"""
2791
2817
v = super (Series , self ).memory_usage (deep = deep )
2792
2818
if index :
0 commit comments