Return the sum of the values over the requested axis. This is equivalent to the method ``numpy.sum``. Parameters ---------- axis : {index (0)} Axis for the function to be applied on. For `Series` this parameter is unused and defaults
(
self,
axis: Axis | None = None,
skipna: bool = True,
numeric_only: bool = False,
min_count: int = 0,
**kwargs,
)
| 7876 | |
| 7877 | @deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="sum") |
| 7878 | def sum( |
| 7879 | self, |
| 7880 | axis: Axis | None = None, |
| 7881 | skipna: bool = True, |
| 7882 | numeric_only: bool = False, |
| 7883 | min_count: int = 0, |
| 7884 | **kwargs, |
| 7885 | ): |
| 7886 | """ |
| 7887 | Return the sum of the values over the requested axis. |
| 7888 | |
| 7889 | This is equivalent to the method ``numpy.sum``. |
| 7890 | |
| 7891 | Parameters |
| 7892 | ---------- |
| 7893 | axis : {index (0)} |
| 7894 | Axis for the function to be applied on. |
| 7895 | For `Series` this parameter is unused and defaults to 0. |
| 7896 | |
| 7897 | .. warning:: |
| 7898 | |
| 7899 | The behavior of DataFrame.sum with ``axis=None`` is deprecated, |
| 7900 | in a future version this will reduce over both axes and return a scalar |
| 7901 | To retain the old behavior, pass axis=0 (or do not pass axis). |
| 7902 | |
| 7903 | .. versionadded:: 2.0.0 |
| 7904 | |
| 7905 | skipna : bool, default True |
| 7906 | Exclude NA/null values when computing the result. |
| 7907 | numeric_only : bool, default False |
| 7908 | Include only float, int, boolean columns. Not implemented for Series. |
| 7909 | |
| 7910 | min_count : int, default 0 |
| 7911 | The required number of valid values to perform the operation. If fewer than |
| 7912 | ``min_count`` non-NA values are present the result will be NA. |
| 7913 | **kwargs |
| 7914 | Additional keyword arguments to be passed to the function. |
| 7915 | |
| 7916 | Returns |
| 7917 | ------- |
| 7918 | scalar or Series (if level specified) |
| 7919 | Sum of the values for the requested axis. |
| 7920 | |
| 7921 | See Also |
| 7922 | -------- |
| 7923 | numpy.sum : Equivalent numpy function for computing sum. |
| 7924 | Series.mean : Mean of the values. |
| 7925 | Series.median : Median of the values. |
| 7926 | Series.std : Standard deviation of the values. |
| 7927 | Series.var : Variance of the values. |
| 7928 | Series.min : Minimum value. |
| 7929 | Series.max : Maximum value. |
| 7930 | |
| 7931 | Examples |
| 7932 | -------- |
| 7933 | >>> idx = pd.MultiIndex.from_arrays( |
| 7934 | ... [["warm", "warm", "cold", "cold"], ["dog", "falcon", "fish", "spider"]], |
| 7935 | ... names=["blooded", "animal"], |
no outgoing calls