Python
#28

Winsorize and Cap Outliers with df.clip() in Pandas

Medium
Interview Question #28

Given a `delivery_time_min` column with extreme outliers (e.g. 5,000 minutes due to sensor errors), winsorize the data by capping values at the 99th percentile upper bound and 1st percentile lower bound.

Input Table: delivery_times
3 rows preview
time_min
15
25
5000
Expected Output Structure3 rows
capped_time_min
15
25
60
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us