From 5d8684fdaf033c1df62c13e259d8cb0c4f305bb8 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 4 May 2024 12:01:37 +0530 Subject: [PATCH 1/3] DOC: add GL08 for pandas.Index.names --- pandas/core/indexes/base.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index e93db22906b39..2161a615e486f 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1799,6 +1799,23 @@ def _get_default_index_names( return names def _get_names(self) -> FrozenList: + """ + Get names on index. + + See Also + -------- + Index.name : Return Index or MultiIndex name. + + Examples + -------- + >>> idx = pd.Index([1, 2, 3], name="x") + >>> idx.names + ['x'] + + >>> idx = s = pd.Index([1, 2, 3], name=("x", "y")) + >>> idx.names + [('x', 'y')] + """ return FrozenList((self.name,)) def _set_names(self, values, *, level=None) -> None: From 27ecfe027138f61159ed1e1e31991e003b0c7c56 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 4 May 2024 12:02:07 +0530 Subject: [PATCH 2/3] DOC: remove GL08 for pandas.Index.names --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 936e3664cfe93..fca035678acb1 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -83,7 +83,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Grouper PR02" \ -i "pandas.Index PR07" \ -i "pandas.Index.join PR07,RT03,SA01" \ - -i "pandas.Index.names GL08" \ -i "pandas.Index.ravel PR01,RT03" \ -i "pandas.Index.str PR01,SA01" \ -i "pandas.Interval PR02" \ From d11ca3e42323598d636a7dbd6126cef1b527e564 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sun, 5 May 2024 10:04:39 +0530 Subject: [PATCH 3/3] DOC: change return type to FrozenList in example --- pandas/core/indexes/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 2161a615e486f..224e9982cacd1 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1810,11 +1810,11 @@ def _get_names(self) -> FrozenList: -------- >>> idx = pd.Index([1, 2, 3], name="x") >>> idx.names - ['x'] + FrozenList(['x']) >>> idx = s = pd.Index([1, 2, 3], name=("x", "y")) >>> idx.names - [('x', 'y')] + FrozenList([('x', 'y')]) """ return FrozenList((self.name,))