
Place within the contest
mediumPlace within the contest
FanDuel Pandas Interview Question
FanDuel pays by finishing position, and two lineups on identical points have to finish level. Standard contest scoring applies: tied lineups share the better position, and the next position down is skipped by as many lineups as tied.
Using the entries DataFrame, find each contest_id, user_id, their points, and their finishing position as place. Sort by contest_id and then by place, and by user_id where lineups are level. Assign the answer to result.
Asked of
- Data Analyst
- Business Analyst
- BI Analyst
- Product Analyst
- Analytics Engineer
- Data Scientist
entriesDataFrame28 rows
| Column Name | Type |
|---|---|
| entry_id | int64 |
| contest_id | str |
| user_id | str |
| joined_at | str |
| points | float64 |
entriesExample Input
| entry_id | contest_id | user_id | joined_at | points |
|---|---|---|---|---|
| 3101 | C1 | U100 | 2024-03-20 18:05:00 | 742.5 |
| 3102 | C1 | U101 | 2024-03-20 18:11:00 | 801 |
| 3103 | C1 | U102 | 2024-03-20 18:14:00 | 801 |
| 3104 | C1 | U103 | 2024-03-20 18:22:00 | 689.5 |
| 3105 | C1 | U104 | 2024-03-20 18:30:00 | 742.5 |
| 3106 | C1 | U105 | 2024-03-20 18:41:00 | 655 |
| 3107 | C1 | U106 | 2024-03-20 18:52:00 | 812.5 |
| 3120 | C4 | U100 | 2024-03-23 17:30:00 | 455.5 |
| 3121 | C4 | U107 | 2024-03-23 17:38:00 | 455.5 |
| 3122 | C4 | U108 | 2024-03-23 17:49:00 | 603 |
| 3123 | C4 | U110 | 2024-03-23 17:55:00 | 588.5 |
| 3124 | C4 | U111 | 2024-03-23 18:04:00 | 721.5 |
Example Output
| contest_id | user_id | points | place |
|---|---|---|---|
| C1 | U106 | 812.5 | 1 |
| C1 | U101 | 801 | 2 |
| C1 | U102 | 801 | 2 |
| C1 | U100 | 742.5 | 4 |
| C1 | U104 | 742.5 | 4 |
| C1 | U103 | 689.5 | 6 |
| C1 | U105 | 655 | 7 |
| C4 | U111 | 721.5 | 1 |
| C4 | U108 | 603 | 2 |
| C4 | U110 | 588.5 | 3 |
| C4 | U100 | 455.5 | 4 |
| C4 | U107 | 455.5 | 4 |
Explanation
In C1 two lineups tie on 801 points and both place second, so the next one down places fourth rather than third. It happens again at 742.5, where two share fourth and the next is sixth.
The example above is a small slice of the data. Your code runs against the full DataFrames.
Company
FanDuel
Difficulty
medium
Topic
ranking
Language
Pandas
Your code
Loading Python in the background. You can start writing.