@@ -6647,7 +6647,6 @@ def max(
6647
6647
)
6648
6648
6649
6649
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "sum" )
6650
- @doc (make_doc ("sum" , ndim = 1 ))
6651
6650
def sum (
6652
6651
self ,
6653
6652
axis : Axis | None = None ,
@@ -6656,6 +6655,89 @@ def sum(
6656
6655
min_count : int = 0 ,
6657
6656
** kwargs ,
6658
6657
):
6658
+ """
6659
+ Return the sum of the values over the requested axis.
6660
+
6661
+ This is equivalent to the method ``numpy.sum``.
6662
+
6663
+ Parameters
6664
+ ----------
6665
+ axis : {index (0)}
6666
+ Axis for the function to be applied on.
6667
+ For `Series` this parameter is unused and defaults to 0.
6668
+
6669
+ .. warning::
6670
+
6671
+ The behavior of DataFrame.sum with ``axis=None`` is deprecated,
6672
+ in a future version this will reduce over both axes and return a scalar
6673
+ To retain the old behavior, pass axis=0 (or do not pass axis).
6674
+
6675
+ .. versionadded:: 2.0.0
6676
+
6677
+ skipna : bool, default True
6678
+ Exclude NA/null values when computing the result.
6679
+ numeric_only : bool, default False
6680
+ Include only float, int, boolean columns. Not implemented for Series.
6681
+
6682
+ min_count : int, default 0
6683
+ The required number of valid values to perform the operation. If fewer than
6684
+ ``min_count`` non-NA values are present the result will be NA.
6685
+ **kwargs
6686
+ Additional keyword arguments to be passed to the function.
6687
+
6688
+ Returns
6689
+ -------
6690
+ scalar or Series (if level specified)
6691
+ Median of the values for the requested axis.
6692
+
6693
+ See Also
6694
+ --------
6695
+ numpy.sum : Equivalent numpy function for computing sum.
6696
+ Series.mean : Mean of the values.
6697
+ Series.median : Median of the values.
6698
+ Series.std : Standard deviation of the values.
6699
+ Series.var : Variance of the values.
6700
+ Series.min : Minimum value.
6701
+ Series.max : Maximum value.
6702
+
6703
+ Examples
6704
+ --------
6705
+ >>> idx = pd.MultiIndex.from_arrays(
6706
+ ... [["warm", "warm", "cold", "cold"], ["dog", "falcon", "fish", "spider"]],
6707
+ ... names=["blooded", "animal"],
6708
+ ... )
6709
+ >>> s = pd.Series([4, 2, 0, 8], name="legs", index=idx)
6710
+ >>> s
6711
+ blooded animal
6712
+ warm dog 4
6713
+ falcon 2
6714
+ cold fish 0
6715
+ spider 8
6716
+ Name: legs, dtype: int64
6717
+
6718
+ >>> s.sum()
6719
+ 14
6720
+
6721
+ By default, the sum of an empty or all-NA Series is ``0``.
6722
+
6723
+ >>> pd.Series([], dtype="float64").sum() # min_count=0 is the default
6724
+ 0.0
6725
+
6726
+ This can be controlled with the ``min_count`` parameter. For example, if
6727
+ you'd like the sum of an empty series to be NaN, pass ``min_count=1``.
6728
+
6729
+ >>> pd.Series([], dtype="float64").sum(min_count=1)
6730
+ nan
6731
+
6732
+ Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
6733
+ empty series identically.
6734
+
6735
+ >>> pd.Series([np.nan]).sum()
6736
+ 0.0
6737
+
6738
+ >>> pd.Series([np.nan]).sum(min_count=1)
6739
+ nan
6740
+ """
6659
6741
return NDFrame .sum (
6660
6742
self ,
6661
6743
axis = axis ,
0 commit comments