Filter DataFrame Rows by Threshold & Status

Basics
BasicsPandasFilteringMetaAmazonUber

Problem

Implement filter_orders(df, min_amount=100.0) returning only rows where status == 'completed' and amount > min_amount (strictly greater), with a clean 0-based reset index.

Why It Matters: Compound boolean filtering with .loc and .reset_index(drop=True) is the #1 everyday Pandas operation in data cleaning and analytics pipelines.

Function Signature

import pandas as pd

def filter_orders(df: pd.DataFrame, min_amount: float = 100.0) -> pd.DataFrame:

Sample Input & Output

Example 1: Standard Filter (min_amount = 100.0)

Input:

order_idstatusamount
1completed150.0
2pending200.0
3completed100.0
4completed250.0
Parameter: 100.0

Expected Output:

order_idstatusamount
1completed150.0
4completed250.0

Explanation: Rows 1 (150.0) and 4 (250.0) pass both filters; row 2 is 'pending' and row 3 equals 100.0 (not strictly greater).

Example 2: No Rows Match (Empty DataFrame)

Input:

order_idstatusamount
1cancelled500.0
2completed50.0
Parameter: 100.0

Expected Output:

order_idstatusamount

Explanation: When no row satisfies both conditions, returns an empty DataFrame preserving the original columns.

Constraints & Edge Cases

  • Return a filtered DataFrame with reset index.
  • Use strict inequality amount > min_amount (not >=).
  • Always chain .reset_index(drop=True) so row indices are 0, 1, ....

Constraints & Evaluation Criteria

  • Return a filtered DataFrame with reset index.

Hints

Python 3
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
4 orders
Expected Output / Criteria
1 matching order