Created
January 5, 2022 21:40
-
-
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
This file contains 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 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) |
Author
misterhay
commented
Jan 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment