Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas between() method is used on series to check which values lie between first and second argument.
Syntax: Series.between(left, right, inclusive=True)
left: A scalar value that defines the left boundary
right: A scalar value that defines the right boundary
inclusive: A Boolean value which is True by default. If False, it excludes the two passed arguments while checking.
Return Type: A Boolean series which is True for every element that lies between the argument values.
To download the CSV file used, Click Here.
Example #1:Values of salary column are checked. If they lie between 80000 and 100000, True is returned.
As shown in the output image, the data frame is having rows only with salary between 80000 and 100000.
Error and exceptions:
- This method doesn’t work on strings.
- This method is only for Series (1D data frame)
- Python | pandas.map()
- Python | Pandas dataframe.min()
- Python | Pandas Series.str.len()
- Python | Pandas Index.contains()
- Python | Pandas Series.sem()
- Python | Pandas.factorize()
- Python | Pandas dataframe.take()
- Python | Pandas dataframe.sum()
- Python | Pandas.melt()
- Python | Pandas dataframe.sem()
- Python | Pandas Series.add()
- Python | Pandas Series.sub()
- Python | Pandas Series.mul()
- Python | Pandas dataframe.std()
- Python | Pandas Series.dt.tz
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.