w3resource
Pandas Tutorial

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.

Syntax:

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

Parameters:

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

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

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

Example:


Download the above Notebook from here.