Skip to content

Commit

Permalink
Create alberta-electricity-generation.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
misterhay committed Jan 16, 2024
1 parent 79f00c9 commit bccf74e
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions content/interesting-problems/alberta-electricity-generation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Alberta Electricity Generation\n",
"\n",
"Let's get the supply and demand report dashboard from [AESO (Alberta Electric System Operator)](http://ets.aeso.ca/ets_web/ip/Market/Reports/CSDReportServlet)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = 'http://ets.aeso.ca/ets_web/ip/Market/Reports/CSDReportServlet'\n",
"\n",
"%pip install -q pyodide_http plotly nbformat\n",
"import pyodide_http\n",
"pyodide_http.patch_all()\n",
"import pandas as pd\n",
"import plotly.express as px\n",
"df = pd.read_html(url, header=0)\n",
"\n",
"updated = df[1].columns[-1].split(': ')[1]\n",
"legend = df[1]['Legend'].values.tolist()\n",
"notes = df[1]['Legend.1'].dropna().values.tolist()\n",
"\n",
"totals = df[5].rename(columns=df[5].iloc[0]).drop(labels=0, axis=0)\n",
"for c in totals.columns[1:]:\n",
" totals[c] = pd.to_numeric(totals[c], errors='ignore')\n",
"\n",
"t = totals[:-1].drop(columns=['DCR'])\n",
"t.columns = ['Group', 'Maximum Capability', 'Total Net Generation']\n",
"t['Group'] = t['Group'].str.title()\n",
"fig1 = px.bar(t, x='Group', y=t.columns[1:3], barmode='group', title='Electricity Generation in Alberta ('+updated+')')\n",
"fig1.update_layout(yaxis_title='Amount (MW)').show()\n",
"px.pie(t, names='Group', values='Maximum Capability', title='Electricity Generation Capacity in Alberta ('+updated+')')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![Callysto.ca License](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-bottom.jpg?raw=true)](https://github.com/callysto/curriculum-notebooks/blob/master/LICENSE.md)"
]
}
],
"metadata": {
"interpreter": {
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
},
"kernelspec": {
"display_name": "Python 3.10.4 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit bccf74e

Please sign in to comment.