101
Boolean indexing
Boolean indexing is defined as a very important feature of numpy, which is frequently used in pandas. Its main task is to use the actual values of the data in the DataFrame. We can filter the data in the boolean indexing in different ways, which are as follows:
- Access the DataFrame with a boolean index.
- Apply the boolean mask to the DataFrame.
- Masking the data based on column value.
- Masking the data based on the index value.
Example1
This example shows the working of how to access the DataFrame with a boolean index:
Output:
name age True Smith 28 True William 39 False Phill 34 True Parker 36
Example2
This example shows the working of how to access the DataFrame with a boolean index by using .loc[]
Output:
name age True Smith 28 True William 39 True Parker 36
Next TopicConcatenating data