Python
All Top Python Interview Questions#46
Ranking Methods in Pandas: min, max, first, dense
MediumAmazonInterview Question #46
Asked at AmazonGiven duplicate salary values, compute rankings using `method='dense'` and `method='min'`. Explain how each handles ties.
Input Table: df
4 rows preview| name | salary |
|---|---|
| Aarav | 100 |
| Bhavna | 90 |
| Chirag | 90 |
| Divya | 80 |
Expected Output Structure4 rows
| name | salary | rank_dense | rank_min |
|---|---|---|---|
| Aarav | 100 | 1 | 1 |
| Bhavna | 90 | 2 | 2 |
| Chirag | 90 | 2 | 2 |
| Divya | 80 | 3 | 4 |
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)…