Skip to content

Instantly share code, notes, and snippets.

@misterhay
Created February 15, 2022 04:49
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/48dbdf2bbc2c93b316f6339073ae4d53 to your computer and use it in GitHub Desktop.
Save misterhay/48dbdf2bbc2c93b316f6339073ae4d53 to your computer and use it in GitHub Desktop.
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