Skip to main contentSkip to solution

How do you select rows from a DataFrame 'df', where the 'Amount' column is greater than 40000?

Solution

✅ Correct Option: 2

Option 2 uses boolean indexing, the standard way to filter rows in pandas. The inner expression df[′Amount′]>40000df['Amount'] > 40000 builds a Series of True/False values, one per row. Passing it to df[…]df[\ldots] keeps only the rows where the value is True.


Options 1 and 3: pandas has no methods called select_rows or filter_rows. Also, 'Amount' > 40000 compares a plain string with a number, which raises an error.

Option 4: pandas has no rows() method. Writing the condition inside quotes only works with df.query('Amount > 40000').

Keyboard Shortcuts

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