From b4d3309e05e0afb7ee5bd671c2150d1e6eebbb88 Mon Sep 17 00:00:00 2001 From: gboeker <68177766+gboeker@users.noreply.github.com> Date: Thu, 2 May 2024 20:44:17 -0400 Subject: [PATCH] DOC: Enforce Numpy Docstring Validation for pandas.Series (#58537) * add see also section for pandas.Series.cat * fix docstring errors for pandas.Series.__iter__ * remove 'pandas' from see also * Improve See Also Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> * Improve See Also --------- Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- ci/code_checks.sh | 3 +-- pandas/core/arrays/categorical.py | 7 ++++++- pandas/core/base.py | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 905c2d0df9065..49410fec36619 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -163,10 +163,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.RangeIndex.start SA01" \ -i "pandas.RangeIndex.step SA01" \ -i "pandas.RangeIndex.stop SA01" \ - -i "pandas.Series.__iter__ RT03,SA01" \ -i "pandas.Series.add PR07" \ -i "pandas.Series.case_when RT03" \ - -i "pandas.Series.cat PR07,SA01" \ + -i "pandas.Series.cat PR07" \ -i "pandas.Series.cat.add_categories PR01,PR02" \ -i "pandas.Series.cat.as_ordered PR01" \ -i "pandas.Series.cat.as_unordered PR01" \ diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index d9bcfd0322d69..381eaaa167d42 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1310,7 +1310,7 @@ def add_categories(self, new_categories) -> Self: Parameters ---------- new_categories : category or list-like of category - The new categories to be included. + The new categories to be included. Returns ------- @@ -2864,6 +2864,11 @@ class CategoricalAccessor(PandasDelegate, PandasObject, NoNewAttributesMixin): ---------- data : Series or CategoricalIndex + See Also + -------- + Series.dt : Accessor object for datetimelike properties of the Series values. + Series.sparse : Accessor for sparse matrix data types. + Examples -------- >>> s = pd.Series(list("abbccc")).astype("category") diff --git a/pandas/core/base.py b/pandas/core/base.py index 87e87538ca1d9..07a7f784b600e 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -870,6 +870,11 @@ def __iter__(self) -> Iterator: Returns ------- iterator + An iterator yielding scalar values from the Series. + + See Also + -------- + Series.items : Lazily iterate over (index, value) tuples. Examples --------