Skip to content

Commit 7138c06

Browse files
Merge branch 'main' into np-doc-df-tomarkdown
2 parents 7f3578a + eadc129 commit 7138c06

File tree

3 files changed

+134
-5
lines changed

3 files changed

+134
-5
lines changed

ci/code_checks.sh

-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8888
-i "pandas.Interval PR02" \
8989
-i "pandas.Interval.closed SA01" \
9090
-i "pandas.Interval.left SA01" \
91-
-i "pandas.Interval.mid SA01" \
9291
-i "pandas.Interval.right SA01" \
9392
-i "pandas.IntervalIndex.closed SA01" \
9493
-i "pandas.IntervalIndex.contains RT03" \
@@ -206,9 +205,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
206205
-i "pandas.Series.list.flatten SA01" \
207206
-i "pandas.Series.list.len SA01" \
208207
-i "pandas.Series.lt PR07,SA01" \
209-
-i "pandas.Series.max RT03" \
210208
-i "pandas.Series.mean RT03,SA01" \
211-
-i "pandas.Series.median RT03,SA01" \
212209
-i "pandas.Series.min RT03" \
213210
-i "pandas.Series.mod PR07" \
214211
-i "pandas.Series.mode SA01" \

pandas/_libs/interval.pyx

+6
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ cdef class IntervalMixin:
167167
"""
168168
Return the midpoint of the Interval.
169169
170+
See Also
171+
--------
172+
Interval.left : Return the left bound for the interval.
173+
Interval.right : Return the right bound for the interval.
174+
Interval.length : Return the length of the interval.
175+
170176
Examples
171177
--------
172178
>>> iv = pd.Interval(0, 5)

pandas/core/series.py

+128-2
Original file line numberDiff line numberDiff line change
@@ -6157,14 +6157,72 @@ def min(
61576157
)
61586158

61596159
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="max")
6160-
@doc(make_doc("max", ndim=1))
61616160
def max(
61626161
self,
61636162
axis: Axis | None = 0,
61646163
skipna: bool = True,
61656164
numeric_only: bool = False,
61666165
**kwargs,
61676166
):
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+
"""
61686226
return NDFrame.max(
61696227
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
61706228
)
@@ -6221,14 +6279,82 @@ def mean(
62216279
)
62226280

62236281
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="median")
6224-
@doc(make_doc("median", ndim=1))
62256282
def median(
62266283
self,
62276284
axis: Axis | None = 0,
62286285
skipna: bool = True,
62296286
numeric_only: bool = False,
62306287
**kwargs,
62316288
) -> Any:
6289+
"""
6290+
Return the median of the values over the requested axis.
6291+
6292+
Parameters
6293+
----------
6294+
axis : {index (0)}
6295+
Axis for the function to be applied on.
6296+
For `Series` this parameter is unused and defaults to 0.
6297+
6298+
For DataFrames, specifying ``axis=None`` will apply the aggregation
6299+
across both axes.
6300+
6301+
.. versionadded:: 2.0.0
6302+
6303+
skipna : bool, default True
6304+
Exclude NA/null values when computing the result.
6305+
numeric_only : bool, default False
6306+
Include only float, int, boolean columns.
6307+
**kwargs
6308+
Additional keyword arguments to be passed to the function.
6309+
6310+
Returns
6311+
-------
6312+
scalar or Series (if level specified)
6313+
Median of the values for the requested axis.
6314+
6315+
See Also
6316+
--------
6317+
numpy.median : Equivalent numpy function for computing median.
6318+
Series.sum : Sum of the values.
6319+
Series.median : Median of the values.
6320+
Series.std : Standard deviation of the values.
6321+
Series.var : Variance of the values.
6322+
Series.min : Minimum value.
6323+
Series.max : Maximum value.
6324+
6325+
Examples
6326+
--------
6327+
>>> s = pd.Series([1, 2, 3])
6328+
>>> s.median()
6329+
2.0
6330+
6331+
With a DataFrame
6332+
6333+
>>> df = pd.DataFrame({"a": [1, 2], "b": [2, 3]}, index=["tiger", "zebra"])
6334+
>>> df
6335+
a b
6336+
tiger 1 2
6337+
zebra 2 3
6338+
>>> df.median()
6339+
a 1.5
6340+
b 2.5
6341+
dtype: float64
6342+
6343+
Using axis=1
6344+
6345+
>>> df.median(axis=1)
6346+
tiger 1.5
6347+
zebra 2.5
6348+
dtype: float64
6349+
6350+
In this case, `numeric_only` should be set to `True`
6351+
to avoid getting an error.
6352+
6353+
>>> df = pd.DataFrame({"a": [1, 2], "b": ["T", "Z"]}, index=["tiger", "zebra"])
6354+
>>> df.median(numeric_only=True)
6355+
a 1.5
6356+
dtype: float64
6357+
"""
62326358
return NDFrame.median(
62336359
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
62346360
)

0 commit comments

Comments
 (0)