Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created August 2, 2020 11:22
Show Gist options
  • Save SaraM92/854e2f989eae83b2d58efa1817790ea2 to your computer and use it in GitHub Desktop.
Save SaraM92/854e2f989eae83b2d58efa1817790ea2 to your computer and use it in GitHub Desktop.
#Import needed libraries
import pygal
import pandas as pd
#Parse the dataframe
data = pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv")
#Get the mean number of cases per states
mean_per_state = data.groupby('state')['cases'].mean()
#Draw the bar chart
barChart = pygal.Bar(height=400)
[barChart.add(x[0], x[1]) for x in mean_per_state.items()]
display(HTML(base_html.format(rendered_chart=barChart.render(is_unicode=True))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment