fixed sticky sidebar
Browse files- .streamlit/config.toml +2 -0
- app.py +8 -5
- test.ipynb +114 -0
.streamlit/config.toml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="light"
|
app.py
CHANGED
@@ -17,7 +17,6 @@ load_dotenv()
|
|
17 |
Groq_Token = os.environ["GROQ_API_KEY"]
|
18 |
hf_token = os.environ["HF_TOKEN"]
|
19 |
models = {"llama3":"llama3-70b-8192","mixtral": "mixtral-8x7b-32768", "llama2": "llama2-70b-4096", "gemma": "gemma-7b-it"}
|
20 |
-
shape_file = os.getenv("SHAPE_FILE")
|
21 |
|
22 |
self_path = os.path.dirname(os.path.abspath(__file__))
|
23 |
|
@@ -36,7 +35,6 @@ st.write(
|
|
36 |
)
|
37 |
|
38 |
# Displaying the centered title
|
39 |
-
st.markdown("<h2 class='title'>VayuBuddy</h2>", unsafe_allow_html=True)
|
40 |
st.markdown("<div style='text-align:center; padding: 20px;'>VayuBuddy makes pollution monitoring easier by bridging the gap between users and datasets.<br>No coding required—just meaningful insights at your fingertips!</div>", unsafe_allow_html=True)
|
41 |
|
42 |
# Center-aligned instruction text with bold formatting
|
@@ -52,12 +50,14 @@ st.markdown("<div style='text-align:center;'>Choose a query from <b>Select a pro
|
|
52 |
# inference_server = "https://api-inference.huggingface.co/models/codellama/CodeLlama-13b-hf"
|
53 |
# inference_server = "https://api-inference.huggingface.co/models/pandasai/bamboo-llm"
|
54 |
|
55 |
-
image_path = "IITGN_Logo.png"
|
56 |
|
57 |
# Display images and text in three columns with specified ratios
|
58 |
-
col1, col2, col3 = st.sidebar.columns((1.
|
59 |
with col2:
|
60 |
st.image(image_path, use_column_width=True)
|
|
|
|
|
61 |
|
62 |
model_name = st.sidebar.selectbox("Select LLM:", ["llama3","mixtral", "gemma"])
|
63 |
|
@@ -181,6 +181,9 @@ if prompt == 'Custom Prompt':
|
|
181 |
prompt = st.chat_input("Ask me anything about air quality!", key=1000)
|
182 |
if prompt :
|
183 |
show = True
|
|
|
|
|
|
|
184 |
|
185 |
if "last_prompt" in st.session_state:
|
186 |
last_prompt = st.session_state["last_prompt"]
|
@@ -221,7 +224,7 @@ df = pd.read_csv("Data.csv")
|
|
221 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
222 |
|
223 |
import geopandas as gpd
|
224 |
-
india = gpd.read_file(
|
225 |
india.loc[india['ST_NM'].isin(['Ladakh', 'Jammu & Kashmir']), 'ST_NM'] = 'Jammu and Kashmir'
|
226 |
import uuid
|
227 |
# df.dtypes
|
|
|
17 |
Groq_Token = os.environ["GROQ_API_KEY"]
|
18 |
hf_token = os.environ["HF_TOKEN"]
|
19 |
models = {"llama3":"llama3-70b-8192","mixtral": "mixtral-8x7b-32768", "llama2": "llama2-70b-4096", "gemma": "gemma-7b-it"}
|
|
|
20 |
|
21 |
self_path = os.path.dirname(os.path.abspath(__file__))
|
22 |
|
|
|
35 |
)
|
36 |
|
37 |
# Displaying the centered title
|
|
|
38 |
st.markdown("<div style='text-align:center; padding: 20px;'>VayuBuddy makes pollution monitoring easier by bridging the gap between users and datasets.<br>No coding required—just meaningful insights at your fingertips!</div>", unsafe_allow_html=True)
|
39 |
|
40 |
# Center-aligned instruction text with bold formatting
|
|
|
50 |
# inference_server = "https://api-inference.huggingface.co/models/codellama/CodeLlama-13b-hf"
|
51 |
# inference_server = "https://api-inference.huggingface.co/models/pandasai/bamboo-llm"
|
52 |
|
53 |
+
image_path = "IITGN_Logo.png"
|
54 |
|
55 |
# Display images and text in three columns with specified ratios
|
56 |
+
col1, col2, col3 = st.sidebar.columns((1.0, 2, 1.0))
|
57 |
with col2:
|
58 |
st.image(image_path, use_column_width=True)
|
59 |
+
st.markdown("<h1 class='title'>VayuBuddy</h1>", unsafe_allow_html=True)
|
60 |
+
|
61 |
|
62 |
model_name = st.sidebar.selectbox("Select LLM:", ["llama3","mixtral", "gemma"])
|
63 |
|
|
|
181 |
prompt = st.chat_input("Ask me anything about air quality!", key=1000)
|
182 |
if prompt :
|
183 |
show = True
|
184 |
+
else:
|
185 |
+
# placeholder for chat input
|
186 |
+
st.chat_input("Select 'Select a Prompt' -> 'Custom Prompt' in the sidebar to ask your own questions.", key=1000, disabled=True)
|
187 |
|
188 |
if "last_prompt" in st.session_state:
|
189 |
last_prompt = st.session_state["last_prompt"]
|
|
|
224 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
225 |
|
226 |
import geopandas as gpd
|
227 |
+
india = gpd.read_file("https://gist.githubusercontent.com/jbrobst/56c13bbbf9d97d187fea01ca62ea5112/raw/e388c4cae20aa53cb5090210a42ebb9b765c0a36/india_states.geojson")
|
228 |
india.loc[india['ST_NM'].isin(['Ladakh', 'Jammu & Kashmir']), 'ST_NM'] = 'Jammu and Kashmir'
|
229 |
import uuid
|
230 |
# df.dtypes
|
test.ipynb
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"ename": "DriverError",
|
10 |
+
"evalue": "None: No such file or directory",
|
11 |
+
"output_type": "error",
|
12 |
+
"traceback": [
|
13 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
14 |
+
"\u001b[0;31mCPLE_OpenFailedError\u001b[0m Traceback (most recent call last)",
|
15 |
+
"File \u001b[0;32mfiona/ogrext.pyx:136\u001b[0m, in \u001b[0;36mfiona.ogrext.gdal_open_vector\u001b[0;34m()\u001b[0m\n",
|
16 |
+
"File \u001b[0;32mfiona/_err.pyx:291\u001b[0m, in \u001b[0;36mfiona._err.exc_wrap_pointer\u001b[0;34m()\u001b[0m\n",
|
17 |
+
"\u001b[0;31mCPLE_OpenFailedError\u001b[0m: None: No such file or directory",
|
18 |
+
"\nDuring handling of the above exception, another exception occurred:\n",
|
19 |
+
"\u001b[0;31mDriverError\u001b[0m Traceback (most recent call last)",
|
20 |
+
"Cell \u001b[0;32mIn[1], line 10\u001b[0m\n\u001b[1;32m 7\u001b[0m df[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTimestamp\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mto_datetime(df[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTimestamp\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mgeopandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mgpd\u001b[39;00m\n\u001b[0;32m---> 10\u001b[0m india \u001b[38;5;241m=\u001b[39m \u001b[43mgpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_file\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mNone\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m \n\u001b[1;32m 11\u001b[0m india\u001b[38;5;241m.\u001b[39mloc[india[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mST_NM\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39misin([\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mLadakh\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mJammu & Kashmir\u001b[39m\u001b[38;5;124m'\u001b[39m]), \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mST_NM\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mJammu and Kashmir\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01muuid\u001b[39;00m\n",
|
21 |
+
"File \u001b[0;32m/opt/anaconda3/envs/zeel_py311/lib/python3.11/site-packages/geopandas/io/file.py:297\u001b[0m, in \u001b[0;36m_read_file\u001b[0;34m(filename, bbox, mask, rows, engine, **kwargs)\u001b[0m\n\u001b[1;32m 294\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 295\u001b[0m path_or_bytes \u001b[38;5;241m=\u001b[39m filename\n\u001b[0;32m--> 297\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read_file_fiona\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 298\u001b[0m \u001b[43m \u001b[49m\u001b[43mpath_or_bytes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrom_bytes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbbox\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbbox\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmask\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrows\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrows\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\n\u001b[1;32m 299\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 301\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 302\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124munknown engine \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mengine\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
22 |
+
"File \u001b[0;32m/opt/anaconda3/envs/zeel_py311/lib/python3.11/site-packages/geopandas/io/file.py:338\u001b[0m, in \u001b[0;36m_read_file_fiona\u001b[0;34m(path_or_bytes, from_bytes, bbox, mask, rows, where, **kwargs)\u001b[0m\n\u001b[1;32m 335\u001b[0m reader \u001b[38;5;241m=\u001b[39m fiona\u001b[38;5;241m.\u001b[39mopen\n\u001b[1;32m 337\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m fiona_env():\n\u001b[0;32m--> 338\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[43mreader\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath_or_bytes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m features:\n\u001b[1;32m 339\u001b[0m crs \u001b[38;5;241m=\u001b[39m features\u001b[38;5;241m.\u001b[39mcrs_wkt\n\u001b[1;32m 340\u001b[0m \u001b[38;5;66;03m# attempt to get EPSG code\u001b[39;00m\n",
|
23 |
+
"File \u001b[0;32m/opt/anaconda3/envs/zeel_py311/lib/python3.11/site-packages/fiona/env.py:457\u001b[0m, in \u001b[0;36mensure_env_with_credentials.<locals>.wrapper\u001b[0;34m(*args, **kwds)\u001b[0m\n\u001b[1;32m 454\u001b[0m session \u001b[38;5;241m=\u001b[39m DummySession()\n\u001b[1;32m 456\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m env_ctor(session\u001b[38;5;241m=\u001b[39msession):\n\u001b[0;32m--> 457\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
|
24 |
+
"File \u001b[0;32m/opt/anaconda3/envs/zeel_py311/lib/python3.11/site-packages/fiona/__init__.py:292\u001b[0m, in \u001b[0;36mopen\u001b[0;34m(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, allow_unsupported_drivers, **kwargs)\u001b[0m\n\u001b[1;32m 289\u001b[0m path \u001b[38;5;241m=\u001b[39m parse_path(fp)\n\u001b[1;32m 291\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m mode \u001b[38;5;129;01min\u001b[39;00m (\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[0;32m--> 292\u001b[0m colxn \u001b[38;5;241m=\u001b[39m \u001b[43mCollection\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 293\u001b[0m \u001b[43m \u001b[49m\u001b[43mpath\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 294\u001b[0m \u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 295\u001b[0m \u001b[43m \u001b[49m\u001b[43mdriver\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdriver\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 296\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 297\u001b[0m \u001b[43m \u001b[49m\u001b[43mlayer\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlayer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 298\u001b[0m \u001b[43m \u001b[49m\u001b[43menabled_drivers\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43menabled_drivers\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 299\u001b[0m \u001b[43m \u001b[49m\u001b[43mallow_unsupported_drivers\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mallow_unsupported_drivers\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 300\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\n\u001b[1;32m 301\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 302\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m mode \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 303\u001b[0m colxn \u001b[38;5;241m=\u001b[39m Collection(\n\u001b[1;32m 304\u001b[0m path,\n\u001b[1;32m 305\u001b[0m mode,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 314\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs\n\u001b[1;32m 315\u001b[0m )\n",
|
25 |
+
"File \u001b[0;32m/opt/anaconda3/envs/zeel_py311/lib/python3.11/site-packages/fiona/collection.py:243\u001b[0m, in \u001b[0;36mCollection.__init__\u001b[0;34m(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, include_fields, wkt_version, allow_unsupported_drivers, **kwargs)\u001b[0m\n\u001b[1;32m 241\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmode \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 242\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msession \u001b[38;5;241m=\u001b[39m Session()\n\u001b[0;32m--> 243\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msession\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 244\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmode \u001b[38;5;129;01min\u001b[39;00m (\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[1;32m 245\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msession \u001b[38;5;241m=\u001b[39m WritingSession()\n",
|
26 |
+
"File \u001b[0;32mfiona/ogrext.pyx:588\u001b[0m, in \u001b[0;36mfiona.ogrext.Session.start\u001b[0;34m()\u001b[0m\n",
|
27 |
+
"File \u001b[0;32mfiona/ogrext.pyx:143\u001b[0m, in \u001b[0;36mfiona.ogrext.gdal_open_vector\u001b[0;34m()\u001b[0m\n",
|
28 |
+
"\u001b[0;31mDriverError\u001b[0m: None: No such file or directory"
|
29 |
+
]
|
30 |
+
}
|
31 |
+
],
|
32 |
+
"source": [
|
33 |
+
"import pandas as pd\n",
|
34 |
+
"import matplotlib.pyplot as plt\n",
|
35 |
+
"\n",
|
36 |
+
"plt.rcParams.update({'font.size': 12, 'figure.dpi': 600})\n",
|
37 |
+
"\n",
|
38 |
+
"df = pd.read_csv(\"Data.csv\")\n",
|
39 |
+
"df[\"Timestamp\"] = pd.to_datetime(df[\"Timestamp\"])\n",
|
40 |
+
"\n",
|
41 |
+
"import geopandas as gpd\n",
|
42 |
+
"india = gpd.read_file(f\"None\")\n",
|
43 |
+
"india.loc[india['ST_NM'].isin(['Ladakh', 'Jammu & Kashmir']), 'ST_NM'] = 'Jammu and Kashmir'\n",
|
44 |
+
"import uuid\n",
|
45 |
+
"# df.dtypes\n",
|
46 |
+
"# Timestamp datetime64[ns]\n",
|
47 |
+
"# station object\n",
|
48 |
+
"# PM2.5 float64\n",
|
49 |
+
"# PM10 float64\n",
|
50 |
+
"# address object\n",
|
51 |
+
"# city object\n",
|
52 |
+
"# latitude float64\n",
|
53 |
+
"# longitude float64\n",
|
54 |
+
"# state object\n",
|
55 |
+
"# dtype: object\n",
|
56 |
+
"\n",
|
57 |
+
"# Plot the monthly average PM2.5 for the year 2023.\n",
|
58 |
+
"# <your code here>\n",
|
59 |
+
"\n",
|
60 |
+
"\n",
|
61 |
+
"import pandas as pd\n",
|
62 |
+
"import matplotlib.pyplot as plt\n",
|
63 |
+
"\n",
|
64 |
+
"plt.rcParams.update({'font.size': 12, 'figure.dpi': 600})\n",
|
65 |
+
"\n",
|
66 |
+
"df = pd.read_csv(\"Data.csv\")\n",
|
67 |
+
"df[\"Timestamp\"] = pd.to_datetime(df[\"Timestamp\"])\n",
|
68 |
+
"\n",
|
69 |
+
"import geopandas as gpd\n",
|
70 |
+
"india = gpd.read_file(f\"None\") \n",
|
71 |
+
"india.loc[india['ST_NM'].isin(['Ladakh', 'Jammu & Kashmir']), 'ST_NM'] = 'Jammu and Kashmir'\n",
|
72 |
+
"\n",
|
73 |
+
"# Plot the monthly average PM2.5 for the year 2023.\n",
|
74 |
+
"df_2023 = df[df['Timestamp'].dt.year == 2023]\n",
|
75 |
+
"monthly_avg_pm25 = df_2023.resample('M', on='Timestamp')['PM2.5'].mean()\n",
|
76 |
+
"\n",
|
77 |
+
"fig, ax = plt.subplots(figsize=(10, 6))\n",
|
78 |
+
"monthly_avg_pm25.plot(kind='bar')\n",
|
79 |
+
"ax.set_title('Monthly Average PM2.5 in 2023')\n",
|
80 |
+
"ax.set_xlabel('Month')\n",
|
81 |
+
"ax.set_ylabel('Average PM2.5 (µg/m³)')\n",
|
82 |
+
"ax.axhline(y=60, color='r', linestyle='--', label='India Guideline')\n",
|
83 |
+
"ax.axhline(y=15, color='b', linestyle='--', label='WHO Guideline')\n",
|
84 |
+
"plt.legend()\n",
|
85 |
+
"plt.tight_layout()\n",
|
86 |
+
"\n",
|
87 |
+
"uuid_str = str(uuid.uuid4())\n",
|
88 |
+
"answer = f'plot_{uuid_str}.png'\n",
|
89 |
+
"plt.savefig(answer)"
|
90 |
+
]
|
91 |
+
}
|
92 |
+
],
|
93 |
+
"metadata": {
|
94 |
+
"kernelspec": {
|
95 |
+
"display_name": "zeel_py311",
|
96 |
+
"language": "python",
|
97 |
+
"name": "python3"
|
98 |
+
},
|
99 |
+
"language_info": {
|
100 |
+
"codemirror_mode": {
|
101 |
+
"name": "ipython",
|
102 |
+
"version": 3
|
103 |
+
},
|
104 |
+
"file_extension": ".py",
|
105 |
+
"mimetype": "text/x-python",
|
106 |
+
"name": "python",
|
107 |
+
"nbconvert_exporter": "python",
|
108 |
+
"pygments_lexer": "ipython3",
|
109 |
+
"version": "3.11.8"
|
110 |
+
}
|
111 |
+
},
|
112 |
+
"nbformat": 4,
|
113 |
+
"nbformat_minor": 2
|
114 |
+
}
|