ibnummuhammad commited on
Commit
2c0c0ca
1 Parent(s): 16c39c1

Add datetime filter for fred data

Browse files
Files changed (1) hide show
  1. coal-price-forecast.ipynb +41 -16
coal-price-forecast.ipynb CHANGED
@@ -30,11 +30,16 @@
30
  "\n",
31
  "csv_path = \"../coal-price-data/fred/\"\n",
32
  "csv_date = \"DATE\"\n",
 
 
33
  "csv_list = os.listdir(csv_path)\n",
34
  "for csv_file in csv_list:\n",
35
  " csv_file = csv_file.split(\".\")[0]\n",
36
  " df[csv_file] = pd.read_csv(f\"../coal-price-data/fred/{csv_file}.csv\")\n",
37
- " df[csv_file][\"datetime\"] = pd.to_datetime(df[csv_file][csv_date], format=\"%Y-%m-%d\")"
 
 
 
38
  ]
39
  },
40
  {
@@ -168,23 +173,43 @@
168
  },
169
  {
170
  "cell_type": "code",
171
- "execution_count": null,
172
- "metadata": {},
173
- "outputs": [],
174
- "source": [
175
- "print(df_coal.min())\n",
176
- "print(df_coal.max())"
177
- ]
178
- },
179
- {
180
- "cell_type": "code",
181
- "execution_count": null,
182
  "metadata": {},
183
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  "source": [
185
- "df_m2_filtered = df_m2.loc[\n",
186
- " (df_m2[\"datetime\"] >= \"2011-11-01\") & (df_m2[\"datetime\"] < \"2023-12-01\")\n",
187
- "]"
 
188
  ]
189
  },
190
  {
 
30
  "\n",
31
  "csv_path = \"../coal-price-data/fred/\"\n",
32
  "csv_date = \"DATE\"\n",
33
+ "csv_date_start = \"2011-11-01\"\n",
34
+ "csv_date_end = \"2023-12-01\"\n",
35
  "csv_list = os.listdir(csv_path)\n",
36
  "for csv_file in csv_list:\n",
37
  " csv_file = csv_file.split(\".\")[0]\n",
38
  " df[csv_file] = pd.read_csv(f\"../coal-price-data/fred/{csv_file}.csv\")\n",
39
+ " df[csv_file][\"datetime\"] = pd.to_datetime(df[csv_file][csv_date], format=\"%Y-%m-%d\")\n",
40
+ " df_m2_filtered = df[csv_file].loc[\n",
41
+ " (df[csv_file][\"datetime\"] >= csv_date_start) & (df[csv_file][\"datetime\"] < csv_date_end)\n",
42
+ " ]"
43
  ]
44
  },
45
  {
 
173
  },
174
  {
175
  "cell_type": "code",
176
+ "execution_count": 5,
 
 
 
 
 
 
 
 
 
 
177
  "metadata": {},
178
+ "outputs": [
179
+ {
180
+ "name": "stdout",
181
+ "output_type": "stream",
182
+ "text": [
183
+ "year 2011\n",
184
+ "date Apr-12\n",
185
+ "newcastle 48.8\n",
186
+ "HBA 49.42\n",
187
+ "ICI_1 52.93\n",
188
+ "datetime 2011-12-01 00:00:00\n",
189
+ "dtype: object\n",
190
+ "year 2023\n",
191
+ "date Sep-23\n",
192
+ "newcastle 433.7\n",
193
+ "HBA 330.97\n",
194
+ "ICI_1 277.62\n",
195
+ "datetime 2023-12-01 00:00:00\n",
196
+ "dtype: object\n",
197
+ "DATE 1959-01-01\n",
198
+ "M2SL 286.6\n",
199
+ "datetime 1959-01-01 00:00:00\n",
200
+ "dtype: object\n",
201
+ "DATE 2023-12-01\n",
202
+ "M2SL 21703.5\n",
203
+ "datetime 2023-12-01 00:00:00\n",
204
+ "dtype: object\n"
205
+ ]
206
+ }
207
+ ],
208
  "source": [
209
+ "print(df[\"coal_price_data\"].min())\n",
210
+ "print(df[\"coal_price_data\"].max())\n",
211
+ "print(df[\"M2SL\"].min())\n",
212
+ "print(df[\"M2SL\"].max())"
213
  ]
214
  },
215
  {