Skip to content

Commit 99d494a

Browse files
DOC: add RT03,SA01 for pandas.Series.mean
1 parent 02708ed commit 99d494a

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

pandas/core/series.py

+70-1
Original file line numberDiff line numberDiff line change
@@ -6208,14 +6208,83 @@ def prod(
62086208
)
62096209

62106210
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="mean")
6211-
@doc(make_doc("mean", ndim=1))
62126211
def mean(
62136212
self,
62146213
axis: Axis | None = 0,
62156214
skipna: bool = True,
62166215
numeric_only: bool = False,
62176216
**kwargs,
62186217
) -> Any:
6218+
"""
6219+
Return the mean of the values over the requested axis.
6220+
6221+
Parameters
6222+
----------
6223+
axis : {index (0)}
6224+
Axis for the function to be applied on.
6225+
For `Series` this parameter is unused and defaults to 0.
6226+
6227+
For DataFrames, specifying ``axis=None`` will apply the aggregation
6228+
across both axes.
6229+
6230+
.. versionadded:: 2.0.0
6231+
6232+
skipna : bool, default True
6233+
Exclude NA/null values when computing the result.
6234+
numeric_only : bool, default False
6235+
Include only float, int, boolean columns.
6236+
**kwargs
6237+
Additional keyword arguments to be passed to the underlying numpy
6238+
function.
6239+
6240+
Returns
6241+
-------
6242+
scalar or Series (if level specified)
6243+
Mean of the values for the requested axis.
6244+
6245+
See Also
6246+
--------
6247+
numpy.mean : Equivalent numpy function.
6248+
Series.sum : Sum of the values.
6249+
Series.median : Median of the values.
6250+
Series.std : Standard deviation of the values.
6251+
Series.var : Variance of the values.
6252+
Series.min : Minimum value.
6253+
Series.max : Maximum value.
6254+
6255+
Examples
6256+
--------
6257+
>>> s = pd.Series([1, 2, 3])
6258+
>>> s.mean()
6259+
2.0
6260+
6261+
With a DataFrame
6262+
6263+
>>> df = pd.DataFrame({"a": [1, 2], "b": [2, 3]}, index=["tiger", "zebra"])
6264+
>>> df
6265+
a b
6266+
tiger 1 2
6267+
zebra 2 3
6268+
>>> df.mean()
6269+
a 1.5
6270+
b 2.5
6271+
dtype: float64
6272+
6273+
Using axis=1
6274+
6275+
>>> df.mean(axis=1)
6276+
tiger 1.5
6277+
zebra 2.5
6278+
dtype: float64
6279+
6280+
In this case, `numeric_only` should be set to `True` to avoid
6281+
getting an error.
6282+
6283+
>>> df = pd.DataFrame({"a": [1, 2], "b": ["T", "Z"]}, index=["tiger", "zebra"])
6284+
>>> df.mean(numeric_only=True)
6285+
a 1.5
6286+
dtype: float64
6287+
"""
62196288
return NDFrame.mean(
62206289
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
62216290
)

0 commit comments

Comments
 (0)