@@ -3556,19 +3556,68 @@ def isin(self, values):
3556
3556
3557
3557
def between (self , left , right , inclusive = True ):
3558
3558
"""
3559
- Return boolean Series equivalent to left <= series <= right. NA values
3560
- will be treated as False
3559
+ Return boolean Series equivalent to left <= series <= right.
3560
+
3561
+ This function returns a boolean vector containing `True` wherever the
3562
+ corresponding Series element is between the boundary values `left` and
3563
+ `right`. NA values are treated as `False`.
3561
3564
3562
3565
Parameters
3563
3566
----------
3564
3567
left : scalar
3565
- Left boundary
3568
+ Left boundary.
3566
3569
right : scalar
3567
- Right boundary
3570
+ Right boundary.
3571
+ inclusive : bool, default True
3572
+ Include boundaries.
3568
3573
3569
3574
Returns
3570
3575
-------
3571
- is_between : Series
3576
+ Series
3577
+ Each element will be a boolean.
3578
+
3579
+ Notes
3580
+ -----
3581
+ This function is equivalent to ``(left <= ser) & (ser <= right)``
3582
+
3583
+ See Also
3584
+ --------
3585
+ pandas.Series.gt : Greater than of series and other
3586
+ pandas.Series.lt : Less than of series and other
3587
+
3588
+ Examples
3589
+ --------
3590
+ >>> s = pd.Series([2, 0, 4, 8, np.nan])
3591
+
3592
+ Boundary values are included by default:
3593
+
3594
+ >>> s.between(1, 4)
3595
+ 0 True
3596
+ 1 False
3597
+ 2 True
3598
+ 3 False
3599
+ 4 False
3600
+ dtype: bool
3601
+
3602
+ With `inclusive` set to ``False`` boundary values are excluded:
3603
+
3604
+ >>> s.between(1, 4, inclusive=False)
3605
+ 0 True
3606
+ 1 False
3607
+ 2 False
3608
+ 3 False
3609
+ 4 False
3610
+ dtype: bool
3611
+
3612
+ `left` and `right` can be any scalar value:
3613
+
3614
+ >>> s = pd.Series(['Alice', 'Bob', 'Carol', 'Eve'])
3615
+ >>> s.between('Anna', 'Daniel')
3616
+ 0 False
3617
+ 1 True
3618
+ 2 True
3619
+ 3 False
3620
+ dtype: bool
3572
3621
"""
3573
3622
if inclusive :
3574
3623
lmask = self >= left
0 commit comments