Spaces:
Sleeping
Sleeping
Praveen998
commited on
Commit
•
5e7223c
1
Parent(s):
a69cbd5
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -26,90 +26,109 @@ def on_btn_click():
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
-
st.title("
|
30 |
(
|
31 |
col1,
|
32 |
col2,
|
33 |
) = st.columns(2)
|
34 |
with col1:
|
35 |
-
option = st.selectbox(" Monthly / Weekly", [" Monthly ", " Weekly"])
|
36 |
-
with col2:
|
37 |
-
option = st.selectbox(" Current / Historical", [" Current ", " Historical"])
|
38 |
-
(
|
39 |
-
col1,
|
40 |
-
col2,
|
41 |
-
) = st.columns(2)
|
42 |
-
with col1:
|
43 |
-
option = st.selectbox(" Median / Mean", [" Median ", " Mean"])
|
44 |
-
with col2:
|
45 |
option = st.selectbox(" San Francisco", [" San Francisco"])
|
46 |
-
(
|
47 |
-
col1,
|
48 |
-
col2,
|
49 |
-
) = st.columns(2)
|
50 |
-
with col1:
|
51 |
-
selected_color = st.color_picker(" Choose a palate", "#FF0000")
|
52 |
with col2:
|
53 |
-
|
54 |
if st.checkbox(" Show raw data"):
|
55 |
st.write("Checkbox checked!")
|
56 |
-
st.
|
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 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
)
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
)
|
102 |
-
|
103 |
-
.
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
109 |
)
|
110 |
-
.
|
111 |
-
|
112 |
-
)
|
113 |
|
114 |
|
115 |
if __name__ == "__main__":
|
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
+
st.title(" Corona Dashboard")
|
30 |
(
|
31 |
col1,
|
32 |
col2,
|
33 |
) = st.columns(2)
|
34 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
option = st.selectbox(" San Francisco", [" San Francisco"])
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
with col2:
|
37 |
+
option = st.selectbox(" Monthly / Weekly", [" Monthly ", " Weekly"])
|
38 |
if st.checkbox(" Show raw data"):
|
39 |
st.write("Checkbox checked!")
|
40 |
+
if st.button(" Visualize"):
|
41 |
+
st.write("Button clicked!")
|
42 |
+
st.subheader(" Global Data")
|
43 |
+
df = pd.read_csv(
|
44 |
+
"https://raw.githubusercontent.com/plotly/datasets/master/volcano_db.csv",
|
45 |
+
encoding="iso-8859-1",
|
46 |
+
)
|
47 |
+
freq = df
|
48 |
+
freq = freq.Country.value_counts().reset_index().rename(columns={"count": "x"})
|
49 |
+
df_v = pd.read_csv(
|
50 |
+
"https://raw.githubusercontent.com/plotly/datasets/master/volcano.csv"
|
51 |
+
)
|
52 |
+
fig = make_subplots(
|
53 |
+
rows=2,
|
54 |
+
cols=2,
|
55 |
+
column_widths=[0.6, 0.4],
|
56 |
+
row_heights=[0.4, 0.6],
|
57 |
+
specs=[
|
58 |
+
[{"type": "scattergeo", "rowspan": 2}, {"type": "bar"}],
|
59 |
+
[None, {"type": "surface"}],
|
60 |
+
],
|
61 |
+
)
|
62 |
+
fig.add_trace(
|
63 |
+
go.Scattergeo(
|
64 |
+
lat=df["Latitude"],
|
65 |
+
lon=df["Longitude"],
|
66 |
+
mode="markers",
|
67 |
+
hoverinfo="text",
|
68 |
+
showlegend=False,
|
69 |
+
marker=dict(color="crimson", size=4, opacity=0.8),
|
70 |
+
),
|
71 |
+
row=1,
|
72 |
+
col=1,
|
73 |
)
|
74 |
+
fig.add_trace(
|
75 |
+
go.Bar(
|
76 |
+
x=freq["x"][0:10],
|
77 |
+
y=freq["Country"][0:10],
|
78 |
+
marker=dict(color="crimson"),
|
79 |
+
showlegend=False,
|
80 |
+
),
|
81 |
+
row=1,
|
82 |
+
col=2,
|
83 |
+
)
|
84 |
+
fig.add_trace(go.Surface(z=df_v.values.tolist(), showscale=False), row=2, col=2)
|
85 |
+
fig.update_geos(
|
86 |
+
projection_type="orthographic",
|
87 |
+
landcolor="white",
|
88 |
+
oceancolor="MidnightBlue",
|
89 |
+
showocean=True,
|
90 |
+
lakecolor="LightBlue",
|
91 |
+
)
|
92 |
+
fig.update_xaxes(tickangle=45)
|
93 |
+
fig.update_layout(
|
94 |
+
template="plotly_dark",
|
95 |
+
margin=dict(r=10, t=25, b=40, l=60),
|
96 |
+
annotations=[
|
97 |
+
dict(
|
98 |
+
text="Source: NOAA",
|
99 |
+
showarrow=False,
|
100 |
+
xref="paper",
|
101 |
+
yref="paper",
|
102 |
+
x=0,
|
103 |
+
y=0,
|
104 |
)
|
105 |
+
],
|
106 |
+
)
|
107 |
+
st.plotly_chart(fig)
|
108 |
+
(
|
109 |
+
col1,
|
110 |
+
col2,
|
111 |
+
) = st.columns(2)
|
112 |
+
with col1:
|
113 |
+
st.table(
|
114 |
+
{
|
115 |
+
"Country": ["USA", "Canada", "UK", "Australia"],
|
116 |
+
"Population (millions)": [331, 38, 66, 25],
|
117 |
+
"GDP (trillion USD)": [22.675, 1.843, 2.855, 1.488],
|
118 |
+
}
|
119 |
)
|
120 |
+
with col2:
|
121 |
+
df = px.data.gapminder().query("year == 2007").query("continent == 'Americas'")
|
122 |
+
fig = px.pie(
|
123 |
+
df,
|
124 |
+
values="pop",
|
125 |
+
names="country",
|
126 |
+
title="Population of American continent",
|
127 |
+
hover_data=["lifeExp"],
|
128 |
+
labels={"lifeExp": "life expectancy"},
|
129 |
)
|
130 |
+
fig.update_traces(textposition="inside", textinfo="percent+label")
|
131 |
+
st.plotly_chart(fig)
|
|
|
132 |
|
133 |
|
134 |
if __name__ == "__main__":
|