From 6e67a826ae69fa964c842b836391431845501698 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 4 May 2024 19:48:23 +0530 Subject: [PATCH 1/2] DOC: add RT03,SA01 for pandas.Series.median --- pandas/core/series.py | 70 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 8474fd0d74919..1294a58a4c816 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6221,7 +6221,6 @@ def mean( ) @deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="median") - @doc(make_doc("median", ndim=1)) def median( self, axis: Axis | None = 0, @@ -6229,6 +6228,75 @@ def median( numeric_only: bool = False, **kwargs, ) -> Any: + """ + Return the median of the values over the requested axis. + + Parameters + ---------- + axis : {index (0)} + 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 + ------- + scalar or Series (if level specified) + Median of the values for the requested axis. + + See Also + -------- + numpy.median : Equivalent numpy function for computing median. + Series.sum : Sum of the values. + Series.median : Median of the values. + Series.std : Standard deviation of the values. + Series.var : Variance of the values. + Series.min : Minimum value. + Series.max : Maximum value. + + Examples + -------- + >>> s = pd.Series([1, 2, 3]) + >>> s.median() + 2.0 + + With a DataFrame + + >>> df = pd.DataFrame({"a": [1, 2], "b": [2, 3]}, index=["tiger", "zebra"]) + >>> df + a b + tiger 1 2 + zebra 2 3 + >>> df.median() + a 1.5 + b 2.5 + dtype: float64 + + Using axis=1 + + >>> df.median(axis=1) + tiger 1.5 + zebra 2.5 + dtype: float64 + + In this case, `numeric_only` should be set to `True` + to avoid getting an error. + + >>> df = pd.DataFrame({"a": [1, 2], "b": ["T", "Z"]}, index=["tiger", "zebra"]) + >>> df.median(numeric_only=True) + a 1.5 + dtype: float64 + """ return NDFrame.median( self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs ) From 3f6cd98640ffee74d6e381370920e828bcf6cd48 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 4 May 2024 19:48:42 +0530 Subject: [PATCH 2/2] DOC: remove RT03,SA01 for pandas.Series.median --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 936e3664cfe93..9f3c573c202b3 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -209,7 +209,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.lt PR07,SA01" \ -i "pandas.Series.max RT03" \ -i "pandas.Series.mean RT03,SA01" \ - -i "pandas.Series.median RT03,SA01" \ -i "pandas.Series.min RT03" \ -i "pandas.Series.mod PR07" \ -i "pandas.Series.mode SA01" \