{ "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_m2_filtered = 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", "
---|---|---|---|
0 | \n", "1959-01-01 | \n", "286.6 | \n", "1959-01-01 | \n", "
1 | \n", "1959-02-01 | \n", "287.7 | \n", "1959-02-01 | \n", "
2 | \n", "1959-03-01 | \n", "289.2 | \n", "1959-03-01 | \n", "
3 | \n", "1959-04-01 | \n", "290.1 | \n", "1959-04-01 | \n", "
4 | \n", "1959-05-01 | \n", "292.2 | \n", "1959-05-01 | \n", "
... | \n", "... | \n", "... | \n", "... | \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", "
779 | \n", "2023-12-01 | \n", "20865.2 | \n", "2023-12-01 | \n", "
780 rows × 3 columns
\n", "