From c470785bc5ed5c5b78dbedad55ac6c5fc1800f15 Mon Sep 17 00:00:00 2001 From: dezmond22 Date: Fri, 23 Oct 2020 23:57:46 +0300 Subject: [PATCH 1/4] DOC: add searchsorted examples --- pandas/core/base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/core/base.py b/pandas/core/base.py index 10b83116dee58..6a89daa574436 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1181,6 +1181,16 @@ def factorize(self, sort: bool = False, na_sentinel: Optional[int] = -1): >>> ser.searchsorted([1, 3], side='right') array([1, 3]) + + >>> ser = pd.Series(pd.to_datetime(['21.10.2020', '22.10.2020', '23.10.2020'])) + >>> ser + 0 2020-10-21 + 1 2020-10-22 + 2 2020-10-23 + dtype: datetime64[ns] + + >>> ser.searchsorted('3/14/2000') + 3 >>> ser = pd.Categorical( ... ['apple', 'bread', 'bread', 'cheese', 'milk'], ordered=True From 77c07c21c7252fbf843dea08e96c747260422536 Mon Sep 17 00:00:00 2001 From: Yury Mikhaylov <44315225+Mikhaylov-yv@users.noreply.github.com> Date: Sat, 24 Oct 2020 00:04:17 +0300 Subject: [PATCH 2/4] Update base.py --- pandas/core/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 6a89daa574436..d9fd046508a80 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1181,14 +1181,14 @@ def factorize(self, sort: bool = False, na_sentinel: Optional[int] = -1): >>> ser.searchsorted([1, 3], side='right') array([1, 3]) - + >>> ser = pd.Series(pd.to_datetime(['21.10.2020', '22.10.2020', '23.10.2020'])) >>> ser 0 2020-10-21 1 2020-10-22 2 2020-10-23 dtype: datetime64[ns] - + >>> ser.searchsorted('3/14/2000') 3 From 5f5392e8272761b5e4645269a12c529b26618c8a Mon Sep 17 00:00:00 2001 From: Yury Mikhaylov <44315225+Mikhaylov-yv@users.noreply.github.com> Date: Sat, 24 Oct 2020 06:26:42 +0300 Subject: [PATCH 3/4] corrected values --- pandas/core/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index d9fd046508a80..6bffe4bf5a259 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1182,7 +1182,7 @@ def factorize(self, sort: bool = False, na_sentinel: Optional[int] = -1): >>> ser.searchsorted([1, 3], side='right') array([1, 3]) - >>> ser = pd.Series(pd.to_datetime(['21.10.2020', '22.10.2020', '23.10.2020'])) + >>> ser = pd.Series(pd.to_datetime(['3/11/2000', '3/12/2000', '3/13/2000'])) >>> ser 0 2020-10-21 1 2020-10-22 From 655bb7a8e185583163d6823e28516cb26a837721 Mon Sep 17 00:00:00 2001 From: Yury Mikhaylov <44315225+Mikhaylov-yv@users.noreply.github.com> Date: Sun, 25 Oct 2020 19:50:27 +0300 Subject: [PATCH 4/4] Update base.py --- pandas/core/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 6bffe4bf5a259..67d5d4a24ae49 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1184,9 +1184,9 @@ def factorize(self, sort: bool = False, na_sentinel: Optional[int] = -1): >>> ser = pd.Series(pd.to_datetime(['3/11/2000', '3/12/2000', '3/13/2000'])) >>> ser - 0 2020-10-21 - 1 2020-10-22 - 2 2020-10-23 + 0 2000-03-11 + 1 2000-03-12 + 2 2000-03-13 dtype: datetime64[ns] >>> ser.searchsorted('3/14/2000')