From 4cac6b634431d4faa7e583fda246354abfb3664e Mon Sep 17 00:00:00 2001 From: shriyakalakata Date: Sat, 27 Apr 2024 12:39:07 -0400 Subject: [PATCH 1/4] Fix PR07,RT03,SA01 errors for Index.insert, Index.intersection --- ci/code_checks.sh | 2 -- pandas/core/indexes/base.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 26c8ae1298630..1f21f48c061e1 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -113,8 +113,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.get_indexer_non_unique PR07,SA01" \ -i "pandas.Index.get_loc PR07,RT03,SA01" \ -i "pandas.Index.identical PR01,SA01" \ - -i "pandas.Index.insert PR07,RT03,SA01" \ - -i "pandas.Index.intersection PR07,RT03,SA01" \ -i "pandas.Index.join PR07,RT03,SA01" \ -i "pandas.Index.names GL08" \ -i "pandas.Index.nunique RT03" \ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 9acab2642f6be..b0cb71d126724 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3082,6 +3082,8 @@ def intersection(self, other, sort: bool = False): Parameters ---------- other : Index or array-like + An Index or an array-like object containing elements to form the + intersection with the original Index. sort : True, False or None, default False Whether to sort the resulting index. @@ -3093,6 +3095,14 @@ def intersection(self, other, sort: bool = False): Returns ------- Index + Returns a new Index object with elements common to both the original Index + and the `other` Index. + + See Also + -------- + Index.union : Form the union of two Index objects. + Index.difference : Return a new Index with elements of index not in other. + Index.isin : Return a boolean array where the index values are in values. Examples -------- @@ -6624,11 +6634,20 @@ def insert(self, loc: int, item) -> Index: Parameters ---------- loc : int + An integer representing the location where the new item will be inserted + into the Index. item : object + An object representing the new item to be inserted into the Index. Returns ------- Index + Returns a new Index object resulting from inserting the specified item at + the specified location within the original Index. + + See Also + -------- + Index.append : Append a collection of Index options together. Examples -------- From c40a358e902f539b910a233369442da0e85f8dc1 Mon Sep 17 00:00:00 2001 From: shriyakalakata <87483933+shriyakalakata@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:13:09 -0400 Subject: [PATCH 2/4] Update pandas/core/indexes/base.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/indexes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index b0cb71d126724..8f5d3fb501a9c 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6647,7 +6647,7 @@ def insert(self, loc: int, item) -> Index: See Also -------- - Index.append : Append a collection of Index options together. + Index.append : Append a collection of Indexes together. Examples -------- From 684b79b8ac7957421d84066777cb6bd687dbedde Mon Sep 17 00:00:00 2001 From: shriyakalakata <87483933+shriyakalakata@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:13:14 -0400 Subject: [PATCH 3/4] Update pandas/core/indexes/base.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/indexes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 8f5d3fb501a9c..a094cdadca593 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6637,7 +6637,7 @@ def insert(self, loc: int, item) -> Index: An integer representing the location where the new item will be inserted into the Index. item : object - An object representing the new item to be inserted into the Index. + The new item to be inserted into the Index. Returns ------- From 52c296418dbcd4e392b9ef0e0f93fb35699792c8 Mon Sep 17 00:00:00 2001 From: shriyakalakata <87483933+shriyakalakata@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:13:19 -0400 Subject: [PATCH 4/4] Update pandas/core/indexes/base.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/indexes/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index a094cdadca593..b6398bc0e9085 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6634,8 +6634,7 @@ def insert(self, loc: int, item) -> Index: Parameters ---------- loc : int - An integer representing the location where the new item will be inserted - into the Index. + The integer location where the new item will be inserted. item : object The new item to be inserted into the Index.