Return the memory usage of the Series. The memory usage can optionally include the contribution of the index and of elements of `object` dtype. Parameters ---------- index : bool, default True Specifies whether to include the memory usag
(self, index: bool = True, deep: bool = False)
| 5944 | ) |
| 5945 | |
| 5946 | def memory_usage(self, index: bool = True, deep: bool = False) -> int: |
| 5947 | """ |
| 5948 | Return the memory usage of the Series. |
| 5949 | |
| 5950 | The memory usage can optionally include the contribution of |
| 5951 | the index and of elements of `object` dtype. |
| 5952 | |
| 5953 | Parameters |
| 5954 | ---------- |
| 5955 | index : bool, default True |
| 5956 | Specifies whether to include the memory usage of the Series index. |
| 5957 | deep : bool, default False |
| 5958 | If True, introspect the data deeply by interrogating |
| 5959 | `object` dtypes for system-level memory consumption, and include |
| 5960 | it in the returned value. |
| 5961 | |
| 5962 | Returns |
| 5963 | ------- |
| 5964 | int |
| 5965 | Bytes of memory consumed. |
| 5966 | |
| 5967 | See Also |
| 5968 | -------- |
| 5969 | numpy.ndarray.nbytes : Total bytes consumed by the elements of the |
| 5970 | array. |
| 5971 | DataFrame.memory_usage : Bytes consumed by a DataFrame. |
| 5972 | |
| 5973 | Examples |
| 5974 | -------- |
| 5975 | >>> s = pd.Series(range(3)) |
| 5976 | >>> s.memory_usage() |
| 5977 | 156 |
| 5978 | |
| 5979 | Not including the index gives the size of the rest of the data, which |
| 5980 | is necessarily smaller: |
| 5981 | |
| 5982 | >>> s.memory_usage(index=False) |
| 5983 | 24 |
| 5984 | |
| 5985 | The memory footprint of `object` values is ignored by default: |
| 5986 | |
| 5987 | >>> s = pd.Series(["a", "b"]) |
| 5988 | >>> s.values |
| 5989 | <ArrowStringArray> |
| 5990 | ['a', 'b'] |
| 5991 | Length: 2, dtype: str |
| 5992 | >>> s.memory_usage() |
| 5993 | 150 |
| 5994 | >>> s.memory_usage(deep=True) |
| 5995 | 150 |
| 5996 | """ |
| 5997 | v = self._memory_usage(deep=deep) |
| 5998 | if index: |
| 5999 | v += self.index.memory_usage(deep=deep) |
| 6000 | return v |
| 6001 | |
| 6002 | def isin(self, values) -> Series: |
| 6003 | """ |