File size: 1,923 Bytes
e174bd2
 
 
 
 
 
 
 
6e47fcb
e174bd2
4418285
 
e174bd2
 
 
 
 
4418285
 
 
 
 
e174bd2
4418285
 
 
 
 
 
 
 
e174bd2
4418285
 
e174bd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b559a4
e174bd2
 
 
 
 
 
4418285
e174bd2
 
 
 
 
 
 
 
 
4418285
e174bd2
 
 
 
 
 
4418285
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import streamlit as st
import pandas as pd
import altair as alt
from datetime import date,timedelta
import numpy as np



forecast_future = pd.read_csv('future_forecast.csv')

forecast_future['ds'] = pd.to_datetime(forecast_future['ds'])

today = date.today()

Day = []
aqi_values = []

for x in range(7):
    current_date = today + timedelta(days=x)
    weekday_name = current_date.strftime('%A')
    
    forecast_row = forecast_future.loc[forecast_future['ds'] == pd.Timestamp(current_date)]
    
    if not forecast_row.empty:
        aqi = np.floor(forecast_row['yhat'].values[0])
        Day.append(weekday_name)
        aqi_values.append(aqi)
    else:
        print(f"Warning: No forecast available for {current_date}")
        Day.append(weekday_name)
        aqi_values.append(None)

forecast_dict = {'Day': Day, 'AQI': aqi_values}
df = pd.DataFrame(forecast_dict)



def aqi_color(aqi):
    if 0 <= aqi <= 50:
        return 'green'
    elif 51 <= aqi <= 100:
        return 'yellow'
    elif 101 <= aqi <= 150:
        return 'orange'
    elif 151 <= aqi <= 200:
        return 'red'
    elif 201 <= aqi <= 300:
        return 'purple'
    elif 301 <= aqi <= 500:
        return 'maroon'
    else:
        return 'gray'

df['Color'] = df['AQI'].apply(aqi_color)

df['Day'] = pd.Categorical(df['Day'], categories=Day, ordered=True)

st.title('Weekly Air Quality Index (AQI) of Navi-Mumbai')
st.write('This app shows the AQI values for each day of the week.')


st.subheader('AQI Bar Chart')
bars = alt.Chart(df).mark_bar().encode(
    x=alt.X('Day'),
    y=alt.Y('AQI', scale=alt.Scale(domain=[0, df['AQI'].max() + 10])),
    color=alt.Color('Color:N', scale=None)
).properties(
    width=600,
    height=400
)

text = bars.mark_text(
    align='center',
    baseline='bottom',
    dy=-15  # Adjusted text position
).encode(
    text='AQI'
)

chart = bars + text

st.altair_chart(chart, use_container_width=True)