@@ -11744,7 +11744,6 @@ def max(
11744
11744
return result
11745
11745
11746
11746
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "sum" )
11747
- @doc (make_doc ("sum" , ndim = 2 ))
11748
11747
def sum (
11749
11748
self ,
11750
11749
axis : Axis | None = 0 ,
@@ -11753,6 +11752,87 @@ def sum(
11753
11752
min_count : int = 0 ,
11754
11753
** kwargs ,
11755
11754
) -> Series :
11755
+ """
11756
+ Return the sum of the values over the requested axis.
11757
+
11758
+ This is equivalent to the method ``numpy.sum``.
11759
+
11760
+ Parameters
11761
+ ----------
11762
+ axis : {index (0), columns (1)}
11763
+ Axis for the function to be applied on.
11764
+ For `Series` this parameter is unused and defaults to 0.
11765
+
11766
+ .. warning::
11767
+
11768
+ The behavior of DataFrame.sum with ``axis=None`` is deprecated,
11769
+ in a future version this will reduce over both axes and return a scalar
11770
+ To retain the old behavior, pass axis=0 (or do not pass axis).
11771
+
11772
+ .. versionadded:: 2.0.0
11773
+
11774
+ skipna : bool, default True
11775
+ Exclude NA/null values when computing the result.
11776
+ numeric_only : bool, default False
11777
+ Include only float, int, boolean columns. Not implemented for Series.
11778
+ min_count : int, default 0
11779
+ The required number of valid values to perform the operation. If fewer than
11780
+ ``min_count`` non-NA values are present the result will be NA.
11781
+ **kwargs
11782
+ Additional keyword arguments to be passed to the function.
11783
+
11784
+ Returns
11785
+ -------
11786
+ Series or scalar
11787
+ Sum over requested axis.
11788
+
11789
+ See Also
11790
+ --------
11791
+ Series.sum : Return the sum over Series values.
11792
+ DataFrame.mean : Return the mean of the values over the requested axis.
11793
+ DataFrame.median : Return the median of the values over the requested axis.
11794
+ DataFrame.mode : Get the mode(s) of each element along the requested axis.
11795
+ DataFrame.std : Return the standard deviation of the values over the
11796
+ requested axis.
11797
+
11798
+ Examples
11799
+ --------
11800
+ >>> idx = pd.MultiIndex.from_arrays(
11801
+ ... [["warm", "warm", "cold", "cold"], ["dog", "falcon", "fish", "spider"]],
11802
+ ... names=["blooded", "animal"],
11803
+ ... )
11804
+ >>> s = pd.Series([4, 2, 0, 8], name="legs", index=idx)
11805
+ >>> s
11806
+ blooded animal
11807
+ warm dog 4
11808
+ falcon 2
11809
+ cold fish 0
11810
+ spider 8
11811
+ Name: legs, dtype: int64
11812
+
11813
+ >>> s.sum()
11814
+ 14
11815
+
11816
+ By default, the sum of an empty or all-NA Series is ``0``.
11817
+
11818
+ >>> pd.Series([], dtype="float64").sum() # min_count=0 is the default
11819
+ 0.0
11820
+
11821
+ This can be controlled with the ``min_count`` parameter. For example, if
11822
+ you'd like the sum of an empty series to be NaN, pass ``min_count=1``.
11823
+
11824
+ >>> pd.Series([], dtype="float64").sum(min_count=1)
11825
+ nan
11826
+
11827
+ Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
11828
+ empty series identically.
11829
+
11830
+ >>> pd.Series([np.nan]).sum()
11831
+ 0.0
11832
+
11833
+ >>> pd.Series([np.nan]).sum(min_count=1)
11834
+ nan
11835
+ """
11756
11836
result = super ().sum (
11757
11837
axis = axis ,
11758
11838
skipna = skipna ,
0 commit comments