{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "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 = {}\n", "\n", "csv_file = \"coal_price_data.csv\"\n", "csv_date = \"date\"\n", "csv_file = csv_file.split(\".\")[0]\n", "df[csv_file] = pd.read_csv(f\"../coal-price-data/{csv_file}.csv\")\n", "df[csv_file][\"datetime\"] = pd.to_datetime(df[csv_file][csv_date], format=\"%b-%y\")\n", "\n", "csv_path = \"../coal-price-data/fred/\"\n", "csv_date = \"DATE\"\n", "csv_date_start = \"2011-11-01\"\n", "csv_date_end = \"2023-12-01\"\n", "csv_list = os.listdir(csv_path)\n", "for csv_file in csv_list:\n", " csv_file = csv_file.split(\".\")[0]\n", " df[csv_file] = pd.read_csv(f\"../coal-price-data/fred/{csv_file}.csv\")\n", " df[csv_file][\"datetime\"] = pd.to_datetime(df[csv_file][csv_date], format=\"%Y-%m-%d\")\n", " df[csv_file] = df[csv_file].loc[\n", " (df[csv_file][\"datetime\"] >= csv_date_start) & (df[csv_file][\"datetime\"] < csv_date_end)\n", " ]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | DATE | \n", "M2SL | \n", "datetime | \n", "
---|---|---|---|
634 | \n", "2011-11-01 | \n", "9612.6 | \n", "2011-11-01 | \n", "
635 | \n", "2011-12-01 | \n", "9660.1 | \n", "2011-12-01 | \n", "
636 | \n", "2012-01-01 | \n", "9733.3 | \n", "2012-01-01 | \n", "
637 | \n", "2012-02-01 | \n", "9785.7 | \n", "2012-02-01 | \n", "
638 | \n", "2012-03-01 | \n", "9830.6 | \n", "2012-03-01 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "
774 | \n", "2023-07-01 | \n", "20863.8 | \n", "2023-07-01 | \n", "
775 | \n", "2023-08-01 | \n", "20825.6 | \n", "2023-08-01 | \n", "
776 | \n", "2023-09-01 | \n", "20755.4 | \n", "2023-09-01 | \n", "
777 | \n", "2023-10-01 | \n", "20725.7 | \n", "2023-10-01 | \n", "
778 | \n", "2023-11-01 | \n", "20767.5 | \n", "2023-11-01 | \n", "
145 rows × 3 columns
\n", "