Skip to content

Instantly share code, notes, and snippets.

@hamletbatista
Created September 28, 2019 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamletbatista/912efefaf0242e23a0579a2da7c5427a to your computer and use it in GitHub Desktop.
Save hamletbatista/912efefaf0242e23a0579a2da7c5427a to your computer and use it in GitHub Desktop.
data = []
ages = ["Pre-K", "Grade School", "Teens", "Young Adults", "Over 30", "Seniors"]
top_5 = []
for i in range(5):
scores = []
for age in ages:
scores.append(tuple(rides.sort_values(age, ascending=False)[[age, "Ride"]].iloc[i].values))
top_5.append(scores)
for scores in top_5:
# bar = go.Bar(showlegend=False, text=["{}: {}".format(x[1], x[0]) for x in scores], textposition="auto", x=ages, y=[x[0] for x in scores])
bar = go.Bar(showlegend=False, text=[x[1] for x in scores], textposition="auto", x=ages, y=[x[0] for x in scores])
data.append(bar)
fig = go.Figure(data=data)
# Change the bar mode
fig.update_layout(barmode='group', width=1400)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment