Pandas Series: between() function

Boolean Series in Pandas

The between() function is used to get boolean Series equivalent to left <= series <= right.

This function returns a boolean vector containing True wherever the corresponding Series element is between the boundary values left and right. NA values are treated as False.


Series.between(self, left, right, inclusive=True)
Pandas Series between image


Name Description Type/Default Value Required / Optional
left Left boundary. scalar Required
right Right boundary. scalar Required
inclusive Include boundaries. bool
Default Value: True

Returns: Series
Series representing whether each element is between left and right (inclusive).

Notes: This function is equivalent to (left <= ser) & (ser <= right)


Download the above Notebook from here.

Previous: Compute the lag-N autocorrelation in Pandas
Next: Trim values at input in Pandas