From 4d4c49d79d50fe0b45e1e819d24d59314e72fa8a Mon Sep 17 00:00:00 2001 From: ktseng37 Date: Wed, 21 Aug 2024 11:39:33 -0700 Subject: [PATCH] update DataFrame.min documentation for RT3 --- ci/code_checks.sh | 1 - pandas/core/frame.py | 59 +++++++++++++++++++++++++++++++++++++++++- pandas/core/generic.py | 10 ------- pandas/core/series.py | 2 +- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 5dbec7f0c8a28..03902b844bd69 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,7 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DataFrame.max RT03" \ -i "pandas.DataFrame.mean RT03" \ -i "pandas.DataFrame.median RT03" \ - -i "pandas.DataFrame.min RT03" \ -i "pandas.DataFrame.plot PR02" \ -i "pandas.Grouper PR02" \ -i "pandas.MultiIndex.append PR07,SA01" \ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a6c0e1e372530..e5726a2bafba5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11692,7 +11692,6 @@ def min( ) -> Series | Any: ... @deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="min") - @doc(make_doc("min", ndim=2)) def min( self, axis: Axis | None = 0, @@ -11700,6 +11699,64 @@ def min( numeric_only: bool = False, **kwargs, ) -> Series | Any: + """ + Return the minimum of the values over the requested axis. + + If you want the *index* of the minimum, use ``idxmin``. + This is the equivalent of the ``numpy.ndarray`` method ``argmin``. + + Parameters + ---------- + axis : {index (0), columns (1)} + Axis for the function to be applied on. + For `Series` this parameter is unused and defaults to 0. + + For DataFrames, specifying ``axis=None`` will apply the aggregation + across both axes. + + .. versionadded:: 2.0.0 + + skipna : bool, default True + Exclude NA/null values when computing the result. + numeric_only : bool, default False + Include only float, int, boolean columns. + **kwargs + Additional keyword arguments to be passed to the function. + + Returns + ------- + Series or scalar + The minimum of the values in the DataFrame. + + See Also + -------- + numpy.min : Equivalent numpy function for arrays. + Series.min : Return the minimum. + Series.max : Return the maximum. + Series.idxmin : Return the index of the minimum. + Series.idxmax : Return the index of the maximum. + DataFrame.max : Return the maximum over the requested axis. + DataFrame.idxmin : Return the index of the minimum over the requested axis. + DataFrame.idxmax : Return the index of the maximum over the requested axis. + + Examples + -------- + >>> idx = pd.MultiIndex.from_arrays( + ... [["warm", "warm", "cold", "cold"], ["dog", "falcon", "fish", "spider"]], + ... names=["blooded", "animal"], + ... ) + >>> s = pd.Series([4, 2, 0, 8], name="legs", index=idx) + >>> s + blooded animal + warm dog 4 + falcon 2 + cold fish 0 + spider 8 + Name: legs, dtype: int64 + + >>> s.min() + 0 + """ result = super().min( axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs ) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 599b3d5578fca..061409f800df2 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -12532,16 +12532,6 @@ def make_doc(name: str, ndim: int) -> str: see_also = _all_see_also examples = _all_examples kwargs = {"empty_value": "True"} - elif name == "min": - base_doc = _num_doc - desc = ( - "Return the minimum of the values over the requested axis.\n\n" - "If you want the *index* of the minimum, use ``idxmin``. This is " - "the equivalent of the ``numpy.ndarray`` method ``argmin``." - ) - see_also = _stat_func_see_also - examples = _min_examples - kwargs = {"min_count": ""} elif name == "max": base_doc = _num_doc desc = ( diff --git a/pandas/core/series.py b/pandas/core/series.py index 3d1bd8ebb03cb..eb3ef6a6f0aea 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6524,7 +6524,7 @@ def min( Returns ------- scalar or Series (if level specified) - The maximum of the values in the Series. + The minimum of the values in the Series. See Also --------