Skip to content

Instantly share code, notes, and snippets.

@misterhay
Created January 5, 2022 21:40
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 misterhay/b24b773a1c890431055cb8303d21ed29 to your computer and use it in GitHub Desktop.
Save misterhay/b24b773a1c890431055cb8303d21ed29 to your computer and use it in GitHub Desktop.
Read data from the Wikipedia article on electricity generation in Alberta and create a pie chart
import pandas as pd
import plotly.express as px
df = pd.read_html('https://en.wikipedia.org/wiki/List_of_generating_stations_in_Alberta')
categories = ['coal','natural gas','dual fuel','biomass','geothermal','hydroelectric','wind','solar']
values = []
for i, c in enumerate(categories):
total = int(pd.to_numeric(df[i+1]['Capacity (MW)'], errors='coerce').sum())
values.append(total)
px.pie(names=categories, values=values)
@misterhay
Copy link
Author

AlbertaEnergyGeneration2022

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