From 8984459517919736dc8674b99c0e1cab17b08e13 Mon Sep 17 00:00:00 2001 From: james-magee Date: Mon, 26 Aug 2024 19:54:14 -0700 Subject: [PATCH 1/4] fixed Series.std and Series.sem docstrings via make_doc --- pandas/core/generic.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index eae3249aa79a4..0778f78f34c7c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -11847,10 +11847,18 @@ def last_valid_index(self) -> Hashable: where N represents the number of elements. numeric_only : bool, default False Include only float, int, boolean columns. Not implemented for Series. +**kwargs : + Additional keywords have no effect but might be accepted + for compatibility with NumPy. Returns ------- -{name1} or {name2} (if level specified) \ +{name1} or {name2} (if level specified) + {return_desc} + +See Also +-------- +{see_also}\ {notes}\ {examples} """ @@ -12706,8 +12714,15 @@ def make_doc(name: str, ndim: int) -> str: "ddof argument." ) examples = _std_examples - see_also = "" - kwargs = {"notes": _std_notes} + see_also = ( + "numpy.std : Compute the standard deviation along the specified axis.\n" + "{name2}.var : Return unbiased variance over requested axis.\n" + "{name2}.sem : Return unbiased standard error of the mean over requested axis.\n" + "{name2}.mean : Return the mean of the values over the requested axis.\n" + "{name2}.median : Return the median of the values over the requested axis.\n" + "{name2}.mode : Return the mode(s) of the Series." + ).format(name2=name2) + kwargs = {"notes": "", "return_desc": "Standard deviation over requested axis."} elif name == "sem": base_doc = _num_ddof_doc @@ -12751,8 +12766,15 @@ def make_doc(name: str, ndim: int) -> str: >>> df.sem(numeric_only=True) a 0.5 dtype: float64""" - see_also = "" - kwargs = {"notes": ""} + see_also = ( + "scipy.stats.sem : Compute standard error of the mean.\n" + "{name2}.std : Return sample standard deviation over requested axis.\n" + "{name2}.var : Return unbiased variance over requested axis.\n" + "{name2}.mean : Return the mean of the values over the requested axis.\n" + "{name2}.median : Return the median of the values over the requested axis.\n" + "{name2}.mode : Return the mode(s) of the Series." + ).format(name2=name2) + kwargs = {"notes": "", "return_desc": "Unbiased standard error of the mean over requested axis."} elif name == "skew": base_doc = _num_doc From 159e4d2eb4cb1eb911db87a9da813ae938115989 Mon Sep 17 00:00:00 2001 From: james-magee Date: Mon, 26 Aug 2024 20:01:23 -0700 Subject: [PATCH 2/4] removed Series.sem, Series.std from ci/code_checks.sh --- ci/code_checks.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 25317a08ca7b0..f0d798312c0c3 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -134,14 +134,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.tz_localize PR01,PR02" \ -i "pandas.Series.dt.unit GL08" \ -i "pandas.Series.pad PR01,SA01" \ - -i "pandas.Series.sem PR01,RT03,SA01" \ -i "pandas.Series.sparse PR01,SA01" \ -i "pandas.Series.sparse.fill_value SA01" \ -i "pandas.Series.sparse.from_coo PR07,SA01" \ -i "pandas.Series.sparse.npoints SA01" \ -i "pandas.Series.sparse.sp_values SA01" \ -i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \ - -i "pandas.Series.std PR01,RT03,SA01" \ -i "pandas.Timedelta.asm8 SA01" \ -i "pandas.Timedelta.ceil SA01" \ -i "pandas.Timedelta.components SA01" \ From ebc0971fb6bee9d9c1478ae85272b1f1fab84149 Mon Sep 17 00:00:00 2001 From: james-magee Date: Mon, 26 Aug 2024 23:59:48 -0700 Subject: [PATCH 3/4] fixed errors from pre-commit --- pandas/core/generic.py | 52 +++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 0778f78f34c7c..37fa054c834d2 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -11847,7 +11847,7 @@ def last_valid_index(self) -> Hashable: where N represents the number of elements. numeric_only : bool, default False Include only float, int, boolean columns. Not implemented for Series. -**kwargs : +**kwargs : Additional keywords have no effect but might be accepted for compatibility with NumPy. @@ -11863,6 +11863,28 @@ def last_valid_index(self) -> Hashable: {examples} """ +_sem_see_also = """\ +scipy.stats.sem : Compute standard error of the mean. +{name2}.std : Return sample standard deviation over requested axis. +{name2}.var : Return unbiased variance over requested axis. +{name2}.mean : Return the mean of the values over the requested axis. +{name2}.median : Return the median of the values over the requested axis. +{name2}.mode : Return the mode(s) of the Series.""" + +_sem_return_desc = """\ +Unbiased standard error of the mean over requested axis.""" + +_std_see_also = """\ +numpy.std : Compute the standard deviation along the specified axis. +{name2}.var : Return unbiased variance over requested axis. +{name2}.sem : Return unbiased standard error of the mean over requested axis. +{name2}.mean : Return the mean of the values over the requested axis. +{name2}.median : Return the median of the values over the requested axis. +{name2}.mode : Return the mode(s) of the Series.""" + +_std_return_desc = """\ +Standard deviation over requested axis.""" + _std_notes = """ Notes @@ -12714,15 +12736,11 @@ def make_doc(name: str, ndim: int) -> str: "ddof argument." ) examples = _std_examples - see_also = ( - "numpy.std : Compute the standard deviation along the specified axis.\n" - "{name2}.var : Return unbiased variance over requested axis.\n" - "{name2}.sem : Return unbiased standard error of the mean over requested axis.\n" - "{name2}.mean : Return the mean of the values over the requested axis.\n" - "{name2}.median : Return the median of the values over the requested axis.\n" - "{name2}.mode : Return the mode(s) of the Series." - ).format(name2=name2) - kwargs = {"notes": "", "return_desc": "Standard deviation over requested axis."} + see_also = _std_see_also.format(name2=name2) + kwargs = { + "notes": "", + "return_desc": _std_return_desc + } elif name == "sem": base_doc = _num_ddof_doc @@ -12766,15 +12784,11 @@ def make_doc(name: str, ndim: int) -> str: >>> df.sem(numeric_only=True) a 0.5 dtype: float64""" - see_also = ( - "scipy.stats.sem : Compute standard error of the mean.\n" - "{name2}.std : Return sample standard deviation over requested axis.\n" - "{name2}.var : Return unbiased variance over requested axis.\n" - "{name2}.mean : Return the mean of the values over the requested axis.\n" - "{name2}.median : Return the median of the values over the requested axis.\n" - "{name2}.mode : Return the mode(s) of the Series." - ).format(name2=name2) - kwargs = {"notes": "", "return_desc": "Unbiased standard error of the mean over requested axis."} + see_also = _sem_see_also.format(name2=name2) + kwargs = { + "notes": "", + "return_desc": _sem_return_desc + } elif name == "skew": base_doc = _num_doc From b1b805870bb9d06df89b62dbb0dc9d9baa83c153 Mon Sep 17 00:00:00 2001 From: james-magee Date: Tue, 27 Aug 2024 00:14:38 -0700 Subject: [PATCH 4/4] ran pre-commit --- pandas/core/generic.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 37fa054c834d2..3109b67a4fc43 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -12737,10 +12737,7 @@ def make_doc(name: str, ndim: int) -> str: ) examples = _std_examples see_also = _std_see_also.format(name2=name2) - kwargs = { - "notes": "", - "return_desc": _std_return_desc - } + kwargs = {"notes": "", "return_desc": _std_return_desc} elif name == "sem": base_doc = _num_ddof_doc @@ -12785,10 +12782,7 @@ def make_doc(name: str, ndim: int) -> str: a 0.5 dtype: float64""" see_also = _sem_see_also.format(name2=name2) - kwargs = { - "notes": "", - "return_desc": _sem_return_desc - } + kwargs = {"notes": "", "return_desc": _sem_return_desc} elif name == "skew": base_doc = _num_doc