{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Import packages\n", "import plotly.express as px\n", "import pandas as pd\n", "\n", "# Import the transform\n", "from scipy.stats import boxcox" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def plotting(title, data, x, y, x_label, y_label, text=False, lam=None):\n", " \"\"\"General function to plot the passenger data.\"\"\"\n", " fig = px.line(data, x=data[x], y=data[y], labels={x: x_label, y: y_label})\n", "\n", " fig.update_layout(\n", " template=\"simple_white\",\n", " font=dict(size=18),\n", " title_text=title,\n", " width=650,\n", " title_x=0.5,\n", " height=400,\n", " )\n", "\n", " if text:\n", " fig.add_annotation(\n", " x=\"1952-12-20\",\n", " y=10,\n", " text=f\"Lambda = {lam:.3f}\",\n", " align=\"left\",\n", " yanchor=\"bottom\",\n", " showarrow=False,\n", " font=dict(size=20, color=\"black\", family=\"Courier New, monospace\"),\n", " bordercolor=\"black\",\n", " borderwidth=2,\n", " bgcolor=\"white\",\n", " )\n", "\n", " fig.show()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Read in the data\n", "data = pd.read_csv(\"../coal-price-data/AirPassengers.csv\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Month | \n", "#Passengers | \n", "
---|---|---|
0 | \n", "1949-01 | \n", "112 | \n", "
1 | \n", "1949-02 | \n", "118 | \n", "
2 | \n", "1949-03 | \n", "132 | \n", "
3 | \n", "1949-04 | \n", "129 | \n", "
4 | \n", "1949-05 | \n", "121 | \n", "
... | \n", "... | \n", "... | \n", "
139 | \n", "1960-08 | \n", "606 | \n", "
140 | \n", "1960-09 | \n", "508 | \n", "
141 | \n", "1960-10 | \n", "461 | \n", "
142 | \n", "1960-11 | \n", "390 | \n", "
143 | \n", "1960-12 | \n", "432 | \n", "
144 rows × 2 columns
\n", "