Relational and Logical Operators with Pandas Series
Explore how to use relational operators and bitwise logical operators with pandas Series to filter and select data. Learn why Python's logical operators cause errors with Series and how to replace them with pandas-compatible operators for accurate Boolean indexing.
We'll cover the following...
We'll cover the following...
Try it yourself
Try executing the code below to see the result.
Explanation
The result of nums > 2 is the series of Boolean values listed below:
In [1]: nums>2
Out[1]:
0 False
1 False
2 True
3 True
4 True
5 True
dtype: bool
We can use this Boolean series to select parts ...