@@ -11709,7 +11709,6 @@ def max(
11709
11709
return result
11710
11710
11711
11711
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "sum" )
11712
- @doc (make_doc ("sum" , ndim = 2 ))
11713
11712
def sum (
11714
11713
self ,
11715
11714
axis : Axis | None = 0 ,
@@ -11718,6 +11717,88 @@ def sum(
11718
11717
min_count : int = 0 ,
11719
11718
** kwargs ,
11720
11719
) -> Series :
11720
+ """
11721
+ Return the sum of the values over the requested axis.
11722
+
11723
+ This is equivalent to the method ``numpy.sum``.
11724
+
11725
+ Parameters
11726
+ ----------
11727
+ axis : {index (0), columns (1)}
11728
+ Axis for the function to be applied on.
11729
+ For `Series` this parameter is unused and defaults to 0.
11730
+
11731
+ .. warning::
11732
+
11733
+ The behavior of DataFrame.sum with ``axis=None`` is deprecated,
11734
+ in a future version this will reduce over both axes and return a scalar
11735
+ To retain the old behavior, pass axis=0 (or do not pass axis).
11736
+
11737
+ .. versionadded:: 2.0.0
11738
+
11739
+ skipna : bool, default True
11740
+ Exclude NA/null values when computing the result.
11741
+ numeric_only : bool, default False
11742
+ Include only float, int, boolean columns. Not implemented for Series.
11743
+
11744
+ min_count : int, default 0
11745
+ The required number of valid values to perform the operation. If fewer than
11746
+ ``min_count`` non-NA values are present the result will be NA.
11747
+ **kwargs
11748
+ Additional keyword arguments to be passed to the function.
11749
+
11750
+ Returns
11751
+ -------
11752
+ Series or scalar
11753
+ Sum over requested axis.
11754
+
11755
+ See Also
11756
+ --------
11757
+ Series.sum : Return the sum over Series values.
11758
+ DataFrame.mean : Return the mean of the values over the requested axis.
11759
+ DataFrame.median : Return the median of the values over the requested axis.
11760
+ DataFrame.mode : Get the mode(s) of each element along the requested axis.
11761
+ DataFrame.std : Return the standard deviation of the values over the
11762
+ requested axis.
11763
+
11764
+ Examples
11765
+ --------
11766
+ >>> idx = pd.MultiIndex.from_arrays(
11767
+ ... [["warm", "warm", "cold", "cold"], ["dog", "falcon", "fish", "spider"]],
11768
+ ... names=["blooded", "animal"],
11769
+ ... )
11770
+ >>> s = pd.Series([4, 2, 0, 8], name="legs", index=idx)
11771
+ >>> s
11772
+ blooded animal
11773
+ warm dog 4
11774
+ falcon 2
11775
+ cold fish 0
11776
+ spider 8
11777
+ Name: legs, dtype: int64
11778
+
11779
+ >>> s.sum()
11780
+ 14
11781
+
11782
+ By default, the sum of an empty or all-NA Series is ``0``.
11783
+
11784
+ >>> pd.Series([], dtype="float64").sum() # min_count=0 is the default
11785
+ 0.0
11786
+
11787
+ This can be controlled with the ``min_count`` parameter. For example, if
11788
+ you'd like the sum of an empty series to be NaN, pass ``min_count=1``.
11789
+
11790
+ >>> pd.Series([], dtype="float64").sum(min_count=1)
11791
+ nan
11792
+
11793
+ Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
11794
+ empty series identically.
11795
+
11796
+ >>> pd.Series([np.nan]).sum()
11797
+ 0.0
11798
+
11799
+ >>> pd.Series([np.nan]).sum(min_count=1)
11800
+ nan
11801
+ """
11721
11802
result = super ().sum (
11722
11803
axis = axis ,
11723
11804
skipna = skipna ,
0 commit comments