Last active
March 21, 2025 15:20
-
-
Save nielsgl/abd1a2e7da930ed96acc70fd22a3a4ab to your computer and use it in GitHub Desktop.
Json scoreboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import requests | |
| import plotly.graph_objects as go | |
| import pandas as pd | |
| gist_url = "https://gist.githubusercontent.com/nielsgl/abd1a2e7da930ed96acc70fd22a3a4ab/raw/83321462bb05725da4b14d43cfd66c2863efa6bf/scoreboard.json" | |
| response = requests.get(gist_url) | |
| response.raise_for_status() | |
| data = json.loads(response.text) | |
| team_names = list(data.keys()) | |
| num_tasks = len(data[team_names[0]]) | |
| task_names = [f"Task {i+1}" for i in range(num_tasks)] | |
| df = pd.DataFrame(data, index=task_names) | |
| total_scores = df.sum(axis=0) | |
| winner = total_scores.idxmax() | |
| winner_score = total_scores.max() | |
| fig_tasks = go.Figure() | |
| for team in team_names: | |
| fig_tasks.add_trace(go.Bar(x=task_names, y=df[team], name=team)) | |
| fig_tasks.update_layout(title="Team Points per Task", xaxis_title="Task", yaxis_title="Points", barmode="group") | |
| fig_tasks.show() | |
| fig_total = go.Figure([go.Bar(x=total_scores.index, y=total_scores.values)]) | |
| fig_total.update_layout( | |
| title=f"Total Points Scored (Winner: {winner} with {winner_score} points)", | |
| xaxis_title="Team", | |
| yaxis_title="Total Points") | |
| fig_total.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "team 1": [2,3,1,0,1], | |
| "team 2": [2,2,3,2,0], | |
| "team 3": [2,1,1,4,2] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! :)