From 9f11f69fe8616229fa965040bf753a915129ca29 Mon Sep 17 00:00:00 2001 From: shriyakalakata Date: Sat, 27 Apr 2024 12:58:40 -0400 Subject: [PATCH 1/2] Fix PR07,RT03,SA01 errors for Index.union, Index.symmetric_difference --- ci/code_checks.sh | 2 -- pandas/core/indexes/base.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 26c8ae1298630..c64bf9525bc0f 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -123,9 +123,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.reindex PR07" \ -i "pandas.Index.slice_indexer PR07,RT03,SA01" \ -i "pandas.Index.str PR01,SA01" \ - -i "pandas.Index.symmetric_difference PR07,RT03,SA01" \ -i "pandas.Index.take PR01,PR07" \ - -i "pandas.Index.union PR07,RT03,SA01" \ -i "pandas.Index.view GL08" \ -i "pandas.Int16Dtype SA01" \ -i "pandas.Int32Dtype SA01" \ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 9acab2642f6be..4034ea852dd6e 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2872,6 +2872,8 @@ def union(self, other, sort=None): Parameters ---------- other : Index or array-like + Another Index or an array-like object containing elements to form the union + with the original Index. sort : bool or None, default None Whether to sort the resulting Index. @@ -2888,6 +2890,14 @@ def union(self, other, sort=None): Returns ------- Index + Returns a new Index object with all unique elements from both the original + Index and the `other` Index. + + See Also + -------- + Index.unique : Return unique values in the index. + Index.intersection : Form the intersection of two Index objects. + Index.difference : Return a new Index with elements of index not in `other`. Examples -------- @@ -3302,7 +3312,10 @@ def symmetric_difference(self, other, result_name=None, sort=None): Parameters ---------- other : Index or array-like + Index or an array-like object with elements to compute the symmetric + difference with the original Index. result_name : str + A string representing the name of the resulting Index, if desired. sort : bool or None, default None Whether to sort the resulting index. By default, the values are attempted to be sorted, but any TypeError from @@ -3316,6 +3329,14 @@ def symmetric_difference(self, other, result_name=None, sort=None): Returns ------- Index + Returns a new Index object containing elements that appear in either the + original Index or the `other` Index, but not both. + + See Also + -------- + Index.difference : Return a new Index with elements of index not in other. + Index.union : Form the union of two Index objects. + Index.intersection : Form the intersection of two Index objects. Notes ----- From 329643778bd2fe70e3b193f42f512bc6a853d460 Mon Sep 17 00:00:00 2001 From: shriyakalakata <87483933+shriyakalakata@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:36:23 -0400 Subject: [PATCH 2/2] 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 4034ea852dd6e..e7a3356e4e12f 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2872,7 +2872,7 @@ def union(self, other, sort=None): Parameters ---------- other : Index or array-like - Another Index or an array-like object containing elements to form the union + Index or an array-like object containing elements to form the union with the original Index. sort : bool or None, default None Whether to sort the resulting Index.