Arrange the following steps to access rows in a pandas DataFrame using Boolean indexing.
(A) Store or display the results
(B) Pass the condition as an index to the DataFrame
(C) Define or create a DataFrame
(D) Write condition to filter rows
Arrange the following steps to access rows in a pandas DataFrame using Boolean indexing.
(A) Store or display the results
(B) Pass the condition as an index to the DataFrame
(C) Define or create a DataFrame
(D) Write condition to filter rows
Solution
✅ Correct Option: 1
(C) Define or create a DataFrame
(D) Write condition to filter rows, e.g. mask = df['marks'] > 50
(B) Pass the condition as an index to the DataFrame, e.g. df[mask]
(A) Store or display the results
Option 4: puts (B) before (D), but the condition must be written before it can be passed as an index.
Related questions:
2026: 13 May Shift 2
2026: 11 May Shift 2
2026: 29 May Shift 2