From a5a7555fd690f2945ec74eb0b3871970fb5bcf3c Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Wed, 3 Apr 2024 12:29:19 -0400 Subject: [PATCH 1/5] add return value if non-existent label is provided in pandas.Index.slice_locs --- pandas/core/indexes/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index a4b58445289ad..1a6d826010c58 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6245,6 +6245,7 @@ def slice_indexer( ----- This function assumes that the data is sorted, so use at your own peril + Examples -------- This is a method on all index types. For example you can do: @@ -6447,6 +6448,7 @@ def slice_locs(self, start=None, end=None, step=None) -> tuple[int, int]: Notes ----- This method only works if the index is monotonic or unique. + If a non-existent label is provided. The return slice location will be where the label will be inserted to maintain the monotonic property. Examples -------- From 6959293ba25f08680e5a73712c77262ef1a52609 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Wed, 3 Apr 2024 12:51:35 -0400 Subject: [PATCH 2/5] fix Line too long error --- pandas/core/indexes/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 1a6d826010c58..a30dd89616fa8 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6448,7 +6448,8 @@ def slice_locs(self, start=None, end=None, step=None) -> tuple[int, int]: Notes ----- This method only works if the index is monotonic or unique. - If a non-existent label is provided. The return slice location will be where the label will be inserted to maintain the monotonic property. + If a non-existent label is provided the return slice location will be + where the label would be inserted to maintain the monotonic property. Examples -------- From c056b0dd454a662574e45ab9e8e0c8c4fd24a9ef Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Wed, 3 Apr 2024 13:00:36 -0400 Subject: [PATCH 3/5] remove trailing whitespace --- 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 a30dd89616fa8..375572704d3a8 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6448,7 +6448,7 @@ def slice_locs(self, start=None, end=None, step=None) -> tuple[int, int]: Notes ----- This method only works if the index is monotonic or unique. - If a non-existent label is provided the return slice location will be + If a non-existent label is provided the return slice location will be where the label would be inserted to maintain the monotonic property. Examples From 4b98933d26d013bd31d5da606934095e53068f59 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Wed, 3 Apr 2024 13:37:13 -0400 Subject: [PATCH 4/5] fix double line break --- pandas/core/indexes/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 375572704d3a8..1804f7c884edc 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6245,7 +6245,6 @@ def slice_indexer( ----- This function assumes that the data is sorted, so use at your own peril - Examples -------- This is a method on all index types. For example you can do: From b848eafd21e3770fa81c6faf4c9fde155495c373 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Wed, 3 Apr 2024 14:08:02 -0400 Subject: [PATCH 5/5] writing as example instead of note --- pandas/core/indexes/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 1804f7c884edc..7da8f6069a668 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6447,14 +6447,16 @@ def slice_locs(self, start=None, end=None, step=None) -> tuple[int, int]: Notes ----- This method only works if the index is monotonic or unique. - If a non-existent label is provided the return slice location will be - where the label would be inserted to maintain the monotonic property. Examples -------- >>> idx = pd.Index(list("abcd")) >>> idx.slice_locs(start="b", end="c") (1, 3) + + >>> idx = pd.Index(list("bcde")) + >>> idx.slice_locs(start="a", end="c") + (0, 2) """ inc = step is None or step >= 0