{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import plotly.express as px\n", "from scipy import stats" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "df_coal = pd.read_csv(\"../coal-price-data/coal_price_data.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yeardatenewcastleHBAICI_1
02023Dec-23146.25117.38118.48
12023Nov-23132.15139.80118.75
22023Oct-23121.10123.96121.70
32023Sep-23160.01133.13116.50
42023Aug-23156.00179.90114.57
..................
1402012Apr-12100.75105.61106.26
1412012Mar-12107.00112.87111.01
1422012Feb-12112.10111.58116.55
1432012Jan-12117.45109.29115.64
1442011Dec-11112.25112.67113.00
\n", "

145 rows × 5 columns

\n", "
" ], "text/plain": [ " year date newcastle HBA ICI_1\n", "0 2023 Dec-23 146.25 117.38 118.48\n", "1 2023 Nov-23 132.15 139.80 118.75\n", "2 2023 Oct-23 121.10 123.96 121.70\n", "3 2023 Sep-23 160.01 133.13 116.50\n", "4 2023 Aug-23 156.00 179.90 114.57\n", ".. ... ... ... ... ...\n", "140 2012 Apr-12 100.75 105.61 106.26\n", "141 2012 Mar-12 107.00 112.87 111.01\n", "142 2012 Feb-12 112.10 111.58 116.55\n", "143 2012 Jan-12 117.45 109.29 115.64\n", "144 2011 Dec-11 112.25 112.67 113.00\n", "\n", "[145 rows x 5 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_coal" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df_coal[\"date\"] = pd.to_datetime(df_coal[\"date\"], format=\"%b-%y\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yeardatenewcastleHBAICI_1
020232023-12-01146.25117.38118.48
120232023-11-01132.15139.80118.75
220232023-10-01121.10123.96121.70
320232023-09-01160.01133.13116.50
420232023-08-01156.00179.90114.57
..................
14020122012-04-01100.75105.61106.26
14120122012-03-01107.00112.87111.01
14220122012-02-01112.10111.58116.55
14320122012-01-01117.45109.29115.64
14420112011-12-01112.25112.67113.00
\n", "

145 rows × 5 columns

\n", "
" ], "text/plain": [ " year date newcastle HBA ICI_1\n", "0 2023 2023-12-01 146.25 117.38 118.48\n", "1 2023 2023-11-01 132.15 139.80 118.75\n", "2 2023 2023-10-01 121.10 123.96 121.70\n", "3 2023 2023-09-01 160.01 133.13 116.50\n", "4 2023 2023-08-01 156.00 179.90 114.57\n", ".. ... ... ... ... ...\n", "140 2012 2012-04-01 100.75 105.61 106.26\n", "141 2012 2012-03-01 107.00 112.87 111.01\n", "142 2012 2012-02-01 112.10 111.58 116.55\n", "143 2012 2012-01-01 117.45 109.29 115.64\n", "144 2011 2011-12-01 112.25 112.67 113.00\n", "\n", "[145 rows x 5 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_coal" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "y = \"newcastle\"" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "fig = px.line(df_coal, x=\"date\", y=y, labels={\"Month\": \"Date\"})" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "date=%{x}
newcastle=%{y}", "legendgroup": "", "line": { "color": "#636efa", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "", "orientation": "v", "showlegend": false, "type": "scatter", "x": [ "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00" ], "xaxis": "x", "y": [ 146.25, 132.15, 121.1, 160.01, 156, 137.3, 128.05, 135, 189.7, 177.25, 192.85, 251.75, 404.15, 398.5, 356.3, 433.7, 425, 407.9, 385.95, 427, 326.6, 259, 274.5, 222.75, 169.6, 152, 223.45, 218, 174.25, 149.75, 134.7, 118.9, 93.3, 96.25, 85.1, 86.2, 80.5, 70.3, 58.2, 58.6, 51.95, 51.95, 52.15, 52, 52.35, 67.85, 67.4, 68.5, 67.7, 67.85, 66.9, 70.05, 65.75, 69.45, 70.9, 83.4, 87.3, 92.75, 96.05, 99, 102.05, 101.7, 105.2, 113.85, 118, 117.55, 114.4, 110.15, 99.4, 96.4, 104.25, 104.35, 100.8, 96.8, 99.9, 97.25, 95.3, 93.2, 81, 73.45, 83.55, 80.75, 83.45, 83, 88.4, 87.45, 108.6, 72.2, 68.75, 61.15, 56.95, 53.5, 50.75, 51.1, 50.5, 48.8, 50.6, 53.55, 53.05, 53.85, 58.5, 60.3, 60.8, 60.05, 62.05, 56.8, 71.05, 62.45, 62.3, 63.45, 64.3, 64.65, 69.25, 68.95, 71.1, 73.9, 73.35, 74.55, 77.55, 82.35, 87.25, 84.55, 84.15, 79.15, 78.55, 77.05, 83, 87.7, 87, 90.65, 94.25, 95.2, 93.75, 85.9, 83.6, 89.5, 91.75, 90.15, 88.4, 91.45, 100.75, 107, 112.1, 117.45, 112.25 ], "yaxis": "y" } ], "layout": { "font": { "size": 18 }, "height": 400, "legend": { "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "rgb(36,36,36)" }, "error_y": { "color": "rgb(36,36,36)" }, "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)" }, "baxis": { "endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "line": { "color": "white", "width": 0.6 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "rgb(237,237,237)" }, "line": { "color": "white" } }, "header": { "fill": { "color": "rgb(217,217,217)" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "colorscale": { "diverging": [ [ 0, "rgb(103,0,31)" ], [ 0.1, "rgb(178,24,43)" ], [ 0.2, "rgb(214,96,77)" ], [ 0.3, "rgb(244,165,130)" ], [ 0.4, "rgb(253,219,199)" ], [ 0.5, "rgb(247,247,247)" ], [ 0.6, "rgb(209,229,240)" ], [ 0.7, "rgb(146,197,222)" ], [ 0.8, "rgb(67,147,195)" ], [ 0.9, "rgb(33,102,172)" ], [ 1, "rgb(5,48,97)" ] ], "sequential": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "sequentialminus": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ] }, "colorway": [ "#1F77B4", "#FF7F0E", "#2CA02C", "#D62728", "#9467BD", "#8C564B", "#E377C2", "#7F7F7F", "#BCBD22", "#17BECF" ], "font": { "color": "rgb(36,36,36)" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "white", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "white", "polar": { "angularaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "bgcolor": "white", "radialaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" } }, "scene": { "xaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "yaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "zaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" } }, "shapedefaults": { "fillcolor": "black", "line": { "width": 0 }, "opacity": 0.3 }, "ternary": { "aaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "baxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "bgcolor": "white", "caxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside", "title": { "standoff": 15 }, "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "yaxis": { "automargin": true, "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside", "title": { "standoff": 15 }, "zeroline": false, "zerolinecolor": "rgb(36,36,36)" } } }, "title": { "text": "Coal Price", "x": 0.5 }, "width": 650, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "date" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "newcastle" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig.update_layout(\n", " template=\"simple_white\",\n", " font=dict(size=18),\n", " title_text=\"Coal Price\",\n", " width=650,\n", " title_x=0.5,\n", " height=400,\n", ")\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = df.newcastle\n", "y = df.ICI_1\n", "\n", "slope, intercept, r, p, std_err = stats.linregress(x, y)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(f\"slope: {slope}\")\n", "print(f\"intercept: {intercept}\")\n", "print(f\"r: {r}\")\n", "print(f\"p: {p}\")\n", "print(f\"std_err: {std_err}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def myfunc(x):\n", " return slope * x + intercept\n", "\n", "\n", "mymodel = list(map(myfunc, x))\n", "\n", "plt.scatter(x, y)\n", "plt.plot(x, mymodel, color=\"orange\")\n", "plt.xlabel(\"Newcastle\")\n", "plt.ylabel(\"ICI 1\")\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.5" } }, "nbformat": 4, "nbformat_minor": 4 }