pandas 1.4.2

NotesParametersReturns
between(self, left, right, inclusive='both') -> 'Series'

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

Notes

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

Parameters

left : scalar or list-like

Left boundary.

right : scalar or list-like

Right boundary.

inclusive : {"both", "neither", "left", "right"}

Include boundaries. Whether to set each bound as closed or open.

versionchanged

Returns

Series

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

Return boolean Series equivalent to left <= series <= right.

See Also

Series.gt

Greater than of series and other.

Series.lt

Less than of series and other.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([2, 0, 4, 8, np.nan])

Boundary values are included by default:

This example is valid syntax, but we were not able to check execution
>>> s.between(1, 4)
0     True
1    False
2     True
3    False
4    False
dtype: bool

With inclusive set to "neither" boundary values are excluded:

This example is valid syntax, but we were not able to check execution
>>> s.between(1, 4, inclusive="neither")
0     True
1    False
2    False
3    False
4    False
dtype: bool

:None:None:`left` and :None:None:`right` can be any scalar value:

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(['Alice', 'Bob', 'Carol', 'Eve'])
... s.between('Anna', 'Daniel') 0 False 1 True 2 True 3 False dtype: bool
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#5146
type: <class 'function'>
Commit: