Spaces:
Sleeping
Sleeping
Commit
·
4600657
1
Parent(s):
230626d
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -26,128 +26,98 @@ 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 |
-
st.
|
36 |
-
pd.DataFrame(
|
37 |
-
{
|
38 |
-
"Apple": yf.download("AAPL", start="2023-01-01", end="2023-07-31")[
|
39 |
-
"Adj Close"
|
40 |
-
],
|
41 |
-
"Google": yf.download(
|
42 |
-
"GOOGL", start="2023-01-01", end="2023-07-31"
|
43 |
-
)["Adj Close"],
|
44 |
-
"Microsoft": yf.download(
|
45 |
-
"MSFT", start="2023-01-01", end="2023-07-31"
|
46 |
-
)["Adj Close"],
|
47 |
-
}
|
48 |
-
)
|
49 |
-
)
|
50 |
with col2:
|
51 |
-
|
52 |
-
|
53 |
-
)
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
),
|
61 |
-
|
|
|
62 |
)
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
"
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
-
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Vega-Lite native theme"])
|
74 |
-
with tab1:
|
75 |
-
st.vega_lite_chart(source, chart, theme="streamlit", use_container_width=True)
|
76 |
-
with tab2:
|
77 |
-
st.vega_lite_chart(source, chart, theme=None, use_container_width=True)
|
78 |
-
st.altair_chart(
|
79 |
-
alt.Chart(
|
80 |
-
pd.DataFrame(
|
81 |
-
{
|
82 |
-
"x": np.random.rand(50),
|
83 |
-
"y": np.random.rand(50),
|
84 |
-
"size": np.random.randint(10, 100, 50),
|
85 |
-
"color": np.random.rand(50),
|
86 |
-
}
|
87 |
-
)
|
88 |
-
)
|
89 |
-
.mark_circle()
|
90 |
-
.encode(
|
91 |
-
x="x",
|
92 |
-
y="y",
|
93 |
-
size="size",
|
94 |
-
color="color",
|
95 |
-
tooltip=["x", "y", "size", "color"],
|
96 |
-
)
|
97 |
-
.properties(width=600, height=400),
|
98 |
-
use_container_width=True,
|
99 |
)
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
)
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
radius=200,
|
118 |
-
elevation_scale=4,
|
119 |
-
elevation_range=[0, 1000],
|
120 |
-
pickable=True,
|
121 |
-
extruded=True,
|
122 |
-
),
|
123 |
-
pdk.Layer(
|
124 |
-
"ScatterplotLayer",
|
125 |
-
data=pd.DataFrame(
|
126 |
-
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
127 |
-
columns=["lat", "lon"],
|
128 |
-
),
|
129 |
-
get_position="[lon, lat]",
|
130 |
-
get_color="[200, 30, 0, 160]",
|
131 |
-
get_radius=200,
|
132 |
-
),
|
133 |
-
],
|
134 |
-
)
|
135 |
)
|
136 |
-
import datetime
|
137 |
-
|
138 |
-
np.random.seed(1)
|
139 |
-
programmers = ["Alex", "Nicole", "Sara", "Etienne", "Chelsea", "Jody", "Marianne"]
|
140 |
-
base = datetime.datetime.today()
|
141 |
-
dates = base - np.arange(180) * datetime.timedelta(days=1)
|
142 |
-
z = np.random.poisson(size=(len(programmers), len(dates)))
|
143 |
-
fig = go.Figure(data=go.Heatmap(z=z, x=dates, y=programmers, colorscale="Viridis"))
|
144 |
-
fig.update_layout(title="GitHub commits per day", xaxis_nticks=36)
|
145 |
st.plotly_chart(fig)
|
146 |
(
|
147 |
col1,
|
148 |
col2,
|
149 |
) = st.columns(2)
|
150 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
df = px.data.gapminder().query("year == 2007").query("continent == 'Americas'")
|
152 |
fig = px.pie(
|
153 |
df,
|
@@ -159,26 +129,6 @@ def main():
|
|
159 |
)
|
160 |
fig.update_traces(textposition="inside", textinfo="percent+label")
|
161 |
st.plotly_chart(fig)
|
162 |
-
with col2:
|
163 |
-
fig = go.Figure(
|
164 |
-
go.Sunburst(
|
165 |
-
labels=[
|
166 |
-
"Eve",
|
167 |
-
"Cain",
|
168 |
-
"Seth",
|
169 |
-
"Enos",
|
170 |
-
"Noam",
|
171 |
-
"Abel",
|
172 |
-
"Awan",
|
173 |
-
"Enoch",
|
174 |
-
"Azura",
|
175 |
-
],
|
176 |
-
parents=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"],
|
177 |
-
values=[10, 14, 12, 10, 2, 6, 6, 4, 4],
|
178 |
-
)
|
179 |
-
)
|
180 |
-
fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
|
181 |
-
st.plotly_chart(fig)
|
182 |
|
183 |
|
184 |
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,
|
|
|
129 |
)
|
130 |
fig.update_traces(textposition="inside", textinfo="percent+label")
|
131 |
st.plotly_chart(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
|
134 |
if __name__ == "__main__":
|