Created
February 15, 2022 04:49
-
-
Save misterhay/48dbdf2bbc2c93b316f6339073ae4d53 to your computer and use it in GitHub Desktop.
Pull data from http://ets.aeso.ca/ets_web/ip/Market/Reports/CSDReportServlet and graph totals
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 | |
url = 'http://ets.aeso.ca/ets_web/ip/Market/Reports/CSDReportServlet' | |
df = pd.read_html(url, header=0) | |
updated = df[1].columns[-1].split(': ')[1] | |
legend = df[1]['Legend'].values.tolist() | |
notes = df[1]['Legend.1'].dropna().values.tolist() | |
totals = df[5].rename(columns=df[5].iloc[0]).drop(labels=0, axis=0) | |
for c in totals.columns[1:]: | |
totals[c] = pd.to_numeric(totals[c], errors='ignore') | |
t = totals[:-1].drop(columns=['DCR']) | |
t.columns = ['Group', 'Maximum Capability', 'Total Net Generation'] | |
t['Group'] = t['Group'].str.title() | |
px.bar(t, x='Group', y=t.columns[1:3], barmode='group', title='Electricity Generation in Alberta ('+updated+')').update_layout(yaxis_title='Amount (MW)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment