Spaces:
Sleeping
Sleeping
Commit
·
5c3a07c
1
Parent(s):
4600657
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -26,109 +26,90 @@ 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(" San Francisco", [" San Francisco"])
|
36 |
-
with col2:
|
37 |
option = st.selectbox(" Monthly / Weekly", [" Monthly ", " Weekly"])
|
38 |
-
|
39 |
-
st.
|
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.
|
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 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
)
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
|
134 |
if __name__ == "__main__":
|
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
+
st.title(" US Real Estate Data and Market Trends")
|
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 |
+
value = st.slider(" No of colors", min_value=0, max_value=100, value=50, key=5)
|
54 |
+
if st.checkbox(" Show raw data"):
|
55 |
+
st.write("Checkbox checked!")
|
56 |
+
st.subheader(" Global 3D Visualization")
|
57 |
+
st.pydeck_chart(
|
58 |
+
pdk.Deck(
|
59 |
+
map_style=None,
|
60 |
+
initial_view_state=pdk.ViewState(
|
61 |
+
latitude=37.76, longitude=-122.4, zoom=11, pitch=50
|
62 |
+
),
|
63 |
+
layers=[
|
64 |
+
pdk.Layer(
|
65 |
+
"HexagonLayer",
|
66 |
+
data=pd.DataFrame(
|
67 |
+
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
68 |
+
columns=["lat", "lon"],
|
69 |
+
),
|
70 |
+
get_position="[lon, lat]",
|
71 |
+
radius=200,
|
72 |
+
elevation_scale=4,
|
73 |
+
elevation_range=[0, 1000],
|
74 |
+
pickable=True,
|
75 |
+
extruded=True,
|
76 |
+
),
|
77 |
+
pdk.Layer(
|
78 |
+
"ScatterplotLayer",
|
79 |
+
data=pd.DataFrame(
|
80 |
+
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
81 |
+
columns=["lat", "lon"],
|
82 |
+
),
|
83 |
+
get_position="[lon, lat]",
|
84 |
+
get_color="[200, 30, 0, 160]",
|
85 |
+
get_radius=200,
|
86 |
+
),
|
87 |
+
],
|
88 |
)
|
89 |
+
)
|
90 |
+
st.subheader(" 2D Visualization")
|
91 |
+
st.altair_chart(
|
92 |
+
alt.Chart(
|
93 |
+
pd.DataFrame(
|
94 |
+
{
|
95 |
+
"x": np.random.rand(50),
|
96 |
+
"y": np.random.rand(50),
|
97 |
+
"size": np.random.randint(10, 100, 50),
|
98 |
+
"color": np.random.rand(50),
|
99 |
+
}
|
100 |
+
)
|
101 |
+
)
|
102 |
+
.mark_circle()
|
103 |
+
.encode(
|
104 |
+
x="x",
|
105 |
+
y="y",
|
106 |
+
size="size",
|
107 |
+
color="color",
|
108 |
+
tooltip=["x", "y", "size", "color"],
|
109 |
+
)
|
110 |
+
.properties(width=600, height=400),
|
111 |
+
use_container_width=True,
|
112 |
+
)
|
113 |
|
114 |
|
115 |
if __name__ == "__main__":
|