Skip to content

Instantly share code, notes, and snippets.

@nielsgl
Last active March 21, 2025 15:20
Show Gist options
  • Select an option

  • Save nielsgl/abd1a2e7da930ed96acc70fd22a3a4ab to your computer and use it in GitHub Desktop.

Select an option

Save nielsgl/abd1a2e7da930ed96acc70fd22a3a4ab to your computer and use it in GitHub Desktop.
Json scoreboard
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()
{
"team 1": [2,3,1,0,1],
"team 2": [2,2,3,2,0],
"team 3": [2,1,1,4,2]
}
@JimmyVlekke
Copy link

Awesome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment