Place within the contest

ranking

Place 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 NameType
entry_idint64
contest_idstr
user_idstr
joined_atstr
pointsfloat64

entriesExample Input

entry_idcontest_iduser_idjoined_atpoints
3101C1U1002024-03-20 18:05:00742.5
3102C1U1012024-03-20 18:11:00801
3103C1U1022024-03-20 18:14:00801
3104C1U1032024-03-20 18:22:00689.5
3105C1U1042024-03-20 18:30:00742.5
3106C1U1052024-03-20 18:41:00655
3107C1U1062024-03-20 18:52:00812.5
3120C4U1002024-03-23 17:30:00455.5
3121C4U1072024-03-23 17:38:00455.5
3122C4U1082024-03-23 17:49:00603
3123C4U1102024-03-23 17:55:00588.5
3124C4U1112024-03-23 18:04:00721.5

Example Output

contest_iduser_idpointsplace
C1U106812.51
C1U1018012
C1U1028012
C1U100742.54
C1U104742.54
C1U103689.56
C1U1056557
C4U111721.51
C4U1086032
C4U110588.53
C4U100455.54
C4U107455.54

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.