@@ -6208,14 +6208,83 @@ def prod(
6208
6208
)
6209
6209
6210
6210
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "mean" )
6211
- @doc (make_doc ("mean" , ndim = 1 ))
6212
6211
def mean (
6213
6212
self ,
6214
6213
axis : Axis | None = 0 ,
6215
6214
skipna : bool = True ,
6216
6215
numeric_only : bool = False ,
6217
6216
** kwargs ,
6218
6217
) -> 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
+ """
6219
6288
return NDFrame .mean (
6220
6289
self , axis = axis , skipna = skipna , numeric_only = numeric_only , ** kwargs
6221
6290
)
0 commit comments