From 3c24787ecb54850f97dcd3d98eae92aacdc462c1 Mon Sep 17 00:00:00 2001 From: shriyakalakata <87483933+shriyakalakata@users.noreply.github.com> Date: Sun, 28 Apr 2024 23:52:32 -0400 Subject: [PATCH] Fix errors for Index.drop, Index.reindex (#58454) --- ci/code_checks.sh | 2 -- pandas/core/indexes/base.py | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 26c8ae1298630..c06277d66f7a9 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -106,7 +106,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index PR07" \ -i "pandas.Index.append PR07,RT03,SA01" \ -i "pandas.Index.difference PR07,RT03,SA01" \ - -i "pandas.Index.drop PR07,SA01" \ -i "pandas.Index.duplicated RT03" \ -i "pandas.Index.get_indexer PR07,SA01" \ -i "pandas.Index.get_indexer_for PR01,SA01" \ @@ -120,7 +119,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.nunique RT03" \ -i "pandas.Index.putmask PR01,RT03" \ -i "pandas.Index.ravel PR01,RT03" \ - -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" \ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 72f36581cd23b..ba8e37d58f08e 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3953,6 +3953,7 @@ def reindex( Parameters ---------- target : an iterable + An iterable containing the values to be used for creating the new index. method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional * default: exact matches only. * pad / ffill: find the PREVIOUS index value if no exact match. @@ -6667,6 +6668,8 @@ def drop( Parameters ---------- labels : array-like or scalar + Array-like object or a scalar value, representing the labels to be removed + from the Index. errors : {'ignore', 'raise'}, default 'raise' If 'ignore', suppress error and existing labels are dropped. @@ -6680,6 +6683,11 @@ def drop( KeyError If not all of the labels are found in the selected axis + See Also + -------- + Index.dropna : Return Index without NA/NaN values. + Index.drop_duplicates : Return Index with duplicate values removed. + Examples -------- >>> idx = pd.Index(["a", "b", "c"])