Skip to content

Commit 0348052

Browse files
committed
Added Colab button and ruffing
1 parent fb5adf3 commit 0348052

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Purple Flamingo Project Part 1.ipynb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@
3737
],
3838
"source": [
3939
"import requests\n",
40+
"\n",
4041
"url = \"https://api.eia.gov/v2/electricity/rto/daily-region-sub-ba-data/data/?frequency=daily&data[0]=value&sort[0][column]=period&sort[0][direction]=desc&offset=0&length=5000&api_key=LTIKgNRTzB9PyNmYCHTfG8sr3A4h2E1RH6O9Swfi\"\n",
4142
"data_request = requests.get(url)\n",
4243
"data = data_request.json()\n",
4344
"print(data)\n",
44-
"print(data.shape)\n"
45+
"print(data.shape)"
4546
]
4647
},
4748
{
@@ -71,7 +72,8 @@
7172
],
7273
"source": [
7374
"import pandas as pd\n",
74-
"type(data)\n"
75+
"\n",
76+
"type(data)"
7577
]
7678
},
7779
{
@@ -208,13 +210,11 @@
208210
}
209211
],
210212
"source": [
211-
"\n",
212213
"df = pd.json_normalize(data[\"response\"][\"data\"])\n",
213214
"df = pd.DataFrame(df)\n",
214215
"type(df)\n",
215216
"print(df.shape)\n",
216-
"df.head()\n",
217-
"\n"
217+
"df.head()"
218218
]
219219
},
220220
{
@@ -233,7 +233,7 @@
233233
"outputs": [],
234234
"source": [
235235
"df[\"value\"] = df[\"value\"].astype(float)\n",
236-
"df[\"valueGWh\"] = df[\"value\"] / 1000\n"
236+
"df[\"valueGWh\"] = df[\"value\"] / 1000"
237237
]
238238
},
239239
{
@@ -288,13 +288,9 @@
288288
}
289289
],
290290
"source": [
291-
"new_df = (\n",
292-
" df.groupby([\"period\", \"parent\"])\n",
293-
" .agg(Demand=(\"valueGWh\", \"sum\"))\n",
294-
" .reset_index()\n",
295-
")\n",
291+
"new_df = df.groupby([\"period\", \"parent\"]).agg(Demand=(\"valueGWh\", \"sum\")).reset_index()\n",
296292
"print(new_df)\n",
297-
"new_df.shape\n"
293+
"new_df.shape"
298294
]
299295
},
300296
{
@@ -323,7 +319,7 @@
323319
"url2 = \"https://api.eia.gov/v2/electricity/rto/daily-fuel-type-data/data/?frequency=daily&data[0]=value&sort[0][column]=period&sort[0][direction]=desc&offset=0&length=5000&api_key=LTIKgNRTzB9PyNmYCHTfG8sr3A4h2E1RH6O9Swfi\"\n",
324320
"data_request2 = requests.get(url2)\n",
325321
"data2 = data_request2.json()\n",
326-
"print(data2)\n"
322+
"print(data2)"
327323
]
328324
},
329325
{
@@ -462,7 +458,7 @@
462458
"df2 = pd.DataFrame(df2)\n",
463459
"type(df2)\n",
464460
"print(df2.shape)\n",
465-
"df2.head()\n"
461+
"df2.head()"
466462
]
467463
},
468464
{
@@ -537,9 +533,11 @@
537533
"source": [
538534
"df2[\"value\"] = df[\"value\"].astype(float)\n",
539535
"df2[\"valueGWh\"] = df[\"value\"] / 1000\n",
540-
"new_df2 = df2.groupby([\"period\", \"type-name\"]).agg(Demand=(\"value\", \"sum\")).reset_index()\n",
536+
"new_df2 = (\n",
537+
" df2.groupby([\"period\", \"type-name\"]).agg(Demand=(\"value\", \"sum\")).reset_index()\n",
538+
")\n",
541539
"print(new_df2)\n",
542-
"new_df2.shape\n"
540+
"new_df2.shape"
543541
]
544542
},
545543
{

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Purple Flamingo: EIA Grid Demand Dashboard
22

3+
<a target="_blank" href="https://colab.research.google.com/github/advanced-computing/purple-flamingo">
4+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
5+
</a>
6+
37
Streamlit dashboard for exploring U.S. electricity demand data from the U.S. Energy Information Administration (EIA).
48

59
## Data Source

0 commit comments

Comments
 (0)