Python
All Top Python Interview Questions#50
Multi-Condition Vectorization with np.select() in Pandas
MediumAmazonInterview Question #50
Asked at AmazonGiven customer tenure in months and spend, categorize customers into: 'VIP' (spend > 100k), 'Loyal' (tenure > 24), 'New High Growth' (spend > 25k and tenure <= 6), and 'Standard' otherwise.
Input Table: df
4 rows preview| name | spend | tenure |
|---|---|---|
| Aarav | 120000 | 12 |
| Bhavna | 15000 | 36 |
| Chirag | 30000 | 3 |
| Divya | 10000 | 10 |
Expected Output Structure4 rows
| name | segment |
|---|---|
| Aarav | VIP |
| Bhavna | Loyal |
| Chirag | New High Growth |
| Divya | Standard |
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
Starting the real Python + pandas runtime (one-time download)…