@@ -6157,14 +6157,72 @@ def min(
6157
6157
)
6158
6158
6159
6159
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "max" )
6160
- @doc (make_doc ("max" , ndim = 1 ))
6161
6160
def max (
6162
6161
self ,
6163
6162
axis : Axis | None = 0 ,
6164
6163
skipna : bool = True ,
6165
6164
numeric_only : bool = False ,
6166
6165
** kwargs ,
6167
6166
):
6167
+ """
6168
+ Return the maximum of the values over the requested axis.
6169
+
6170
+ If you want the *index* of the maximum, use ``idxmax``.
6171
+ This is the equivalent of the ``numpy.ndarray`` method ``argmax``.
6172
+
6173
+ Parameters
6174
+ ----------
6175
+ axis : {index (0)}
6176
+ Axis for the function to be applied on.
6177
+ For `Series` this parameter is unused and defaults to 0.
6178
+
6179
+ For DataFrames, specifying ``axis=None`` will apply the aggregation
6180
+ across both axes.
6181
+
6182
+ .. versionadded:: 2.0.0
6183
+
6184
+ skipna : bool, default True
6185
+ Exclude NA/null values when computing the result.
6186
+ numeric_only : bool, default False
6187
+ Include only float, int, boolean columns.
6188
+ **kwargs
6189
+ Additional keyword arguments to be passed to the function.
6190
+
6191
+ Returns
6192
+ -------
6193
+ scalar or Series (if level specified)
6194
+ The maximum of the values in the Series.
6195
+
6196
+ See Also
6197
+ --------
6198
+ numpy.max : Equivalent numpy function for arrays.
6199
+ Series.min : Return the minimum.
6200
+ Series.max : Return the maximum.
6201
+ Series.idxmin : Return the index of the minimum.
6202
+ Series.idxmax : Return the index of the maximum.
6203
+ DataFrame.min : Return the minimum over the requested axis.
6204
+ DataFrame.max : Return the maximum over the requested axis.
6205
+ DataFrame.idxmin : Return the index of the minimum over the requested axis.
6206
+ DataFrame.idxmax : Return the index of the maximum over the requested axis.
6207
+
6208
+ Examples
6209
+ --------
6210
+ >>> idx = pd.MultiIndex.from_arrays(
6211
+ ... [["warm", "warm", "cold", "cold"], ["dog", "falcon", "fish", "spider"]],
6212
+ ... names=["blooded", "animal"],
6213
+ ... )
6214
+ >>> s = pd.Series([4, 2, 0, 8], name="legs", index=idx)
6215
+ >>> s
6216
+ blooded animal
6217
+ warm dog 4
6218
+ falcon 2
6219
+ cold fish 0
6220
+ spider 8
6221
+ Name: legs, dtype: int64
6222
+
6223
+ >>> s.max()
6224
+ 8
6225
+ """
6168
6226
return NDFrame .max (
6169
6227
self , axis = axis , skipna = skipna , numeric_only = numeric_only , ** kwargs
6170
6228
)
@@ -6290,14 +6348,82 @@ def mean(
6290
6348
)
6291
6349
6292
6350
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "median" )
6293
- @doc (make_doc ("median" , ndim = 1 ))
6294
6351
def median (
6295
6352
self ,
6296
6353
axis : Axis | None = 0 ,
6297
6354
skipna : bool = True ,
6298
6355
numeric_only : bool = False ,
6299
6356
** kwargs ,
6300
6357
) -> Any :
6358
+ """
6359
+ Return the median of the values over the requested axis.
6360
+
6361
+ Parameters
6362
+ ----------
6363
+ axis : {index (0)}
6364
+ Axis for the function to be applied on.
6365
+ For `Series` this parameter is unused and defaults to 0.
6366
+
6367
+ For DataFrames, specifying ``axis=None`` will apply the aggregation
6368
+ across both axes.
6369
+
6370
+ .. versionadded:: 2.0.0
6371
+
6372
+ skipna : bool, default True
6373
+ Exclude NA/null values when computing the result.
6374
+ numeric_only : bool, default False
6375
+ Include only float, int, boolean columns.
6376
+ **kwargs
6377
+ Additional keyword arguments to be passed to the function.
6378
+
6379
+ Returns
6380
+ -------
6381
+ scalar or Series (if level specified)
6382
+ Median of the values for the requested axis.
6383
+
6384
+ See Also
6385
+ --------
6386
+ numpy.median : Equivalent numpy function for computing median.
6387
+ Series.sum : Sum of the values.
6388
+ Series.median : Median of the values.
6389
+ Series.std : Standard deviation of the values.
6390
+ Series.var : Variance of the values.
6391
+ Series.min : Minimum value.
6392
+ Series.max : Maximum value.
6393
+
6394
+ Examples
6395
+ --------
6396
+ >>> s = pd.Series([1, 2, 3])
6397
+ >>> s.median()
6398
+ 2.0
6399
+
6400
+ With a DataFrame
6401
+
6402
+ >>> df = pd.DataFrame({"a": [1, 2], "b": [2, 3]}, index=["tiger", "zebra"])
6403
+ >>> df
6404
+ a b
6405
+ tiger 1 2
6406
+ zebra 2 3
6407
+ >>> df.median()
6408
+ a 1.5
6409
+ b 2.5
6410
+ dtype: float64
6411
+
6412
+ Using axis=1
6413
+
6414
+ >>> df.median(axis=1)
6415
+ tiger 1.5
6416
+ zebra 2.5
6417
+ dtype: float64
6418
+
6419
+ In this case, `numeric_only` should be set to `True`
6420
+ to avoid getting an error.
6421
+
6422
+ >>> df = pd.DataFrame({"a": [1, 2], "b": ["T", "Z"]}, index=["tiger", "zebra"])
6423
+ >>> df.median(numeric_only=True)
6424
+ a 1.5
6425
+ dtype: float64
6426
+ """
6301
6427
return NDFrame .median (
6302
6428
self , axis = axis , skipna = skipna , numeric_only = numeric_only , ** kwargs
6303
6429
)
0 commit comments