Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question