Rank the App Leaderboard
Problem
You are given a DataFrame `leaderboard` (loaded from `leaderboard.csv`) describing games on an app store, with columns `title`, `five_star`, `four_star`, and `three_star` holding the count of reviews at each star rating.
Return the rows sorted by `five_star` descending, then `four_star` descending, then `three_star` descending, and finally `title` ascending to break any remaining ties. The output columns must be `title`, `five_star`, `four_star`, `three_star`.
Input data
Example rows — the live problem includes the full dataset.
| title | five_star | four_star | three_star |
|---|---|---|---|
| Skyforge | 10 | 10 | 20 |
| Tidepool | 0 | 0 | 1 |
| Aether Run | 10 | 10 | 20 |
| Mossgarden | 2 | 2 | 3 |
| Pixel Forge | 2 | 2 | 2 |
Expected output
Your answer should return 5 rows with the columns title, five_star, four_star, three_star.
Starter code (Pandas (Python))
import pandas as pd
def rank_the_app_leaderboard(leaderboard) -> pd.DataFrame:
# Your code here
return leaderboardSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock