Given watchtime(video_id, user_id, minutes), return the top 2 rows for each user_id by minutes descending (ties broken by video_id ascending). Project user_id, video_id, minutes. Sort by user_id asc, minutes desc, video_id asc.
| video_id | user_id | minutes |
|---|---|---|
| 1 | 4 | 97 |
| 2 | 1 | 36 |
| 3 | 4 | 47 |
| 4 | 4 | 68 |
| 5 | 3 | 109 |
| 6 | 1 | 34 |
These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].
watchtime12 rows| video_id (int) | user_id (int) | minutes (int) |
|---|---|---|
| 1 | 4 | 97 |
| 2 | 1 | 36 |
| 3 | 4 | 47 |
| 4 | 4 | 68 |
| 5 | 3 | 109 |
| 6 | 1 | 34 |
| 7 | 4 | 99 |
| 8 | 1 | 6 |
| 9 | 3 | 46 |
| 10 | 3 | 34 |
| 11 | 2 | 114 |
| 12 | 1 | 113 |
Column names and order must match. Sort order is specified in the question.