Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,15 +6,15 @@ df = pd.read_csv("AB_NYC_2019.csv")
|
|
6 |
|
7 |
def filter_map(min_price, max_price, boroughs):
|
8 |
|
9 |
-
|
10 |
(df['price'] > min_price) & (df['price'] < max_price)]
|
11 |
-
names =
|
12 |
-
prices =
|
13 |
text_list = [(names[i], prices[i]) for i in range(0, len(names))]
|
14 |
fig = go.Figure(go.Scattermapbox(
|
15 |
customdata=text_list,
|
16 |
-
lat=
|
17 |
-
lon=
|
18 |
mode='markers',
|
19 |
marker=go.scattermapbox.Marker(
|
20 |
size=6
|
@@ -46,7 +46,7 @@ with gr.Blocks() as demo:
|
|
46 |
max_price = gr.Number(value=1000, label="Maximum Price")
|
47 |
boroughs = gr.CheckboxGroup(choices=["Queens", "Brooklyn", "Manhattan", "Bronx", "Staten Island"], value=["Queens", "Brooklyn"], label="Select Boroughs:")
|
48 |
btn = gr.Button(value="Update Filter")
|
49 |
-
map = gr.Plot()
|
50 |
demo.load(filter_map, [min_price, max_price, boroughs], map)
|
51 |
btn.click(filter_map, [min_price, max_price, boroughs], map)
|
52 |
|
|
|
6 |
|
7 |
def filter_map(min_price, max_price, boroughs):
|
8 |
|
9 |
+
filtered_df = df[(df['neighbourhood_group'].isin(boroughs)) &
|
10 |
(df['price'] > min_price) & (df['price'] < max_price)]
|
11 |
+
names = filtered_df["name"].tolist()
|
12 |
+
prices = filtered_df["price"].tolist()
|
13 |
text_list = [(names[i], prices[i]) for i in range(0, len(names))]
|
14 |
fig = go.Figure(go.Scattermapbox(
|
15 |
customdata=text_list,
|
16 |
+
lat=filtered_df['latitude'].tolist(),
|
17 |
+
lon=filtered_df['longitude'].tolist(),
|
18 |
mode='markers',
|
19 |
marker=go.scattermapbox.Marker(
|
20 |
size=6
|
|
|
46 |
max_price = gr.Number(value=1000, label="Maximum Price")
|
47 |
boroughs = gr.CheckboxGroup(choices=["Queens", "Brooklyn", "Manhattan", "Bronx", "Staten Island"], value=["Queens", "Brooklyn"], label="Select Boroughs:")
|
48 |
btn = gr.Button(value="Update Filter")
|
49 |
+
map = gr.Plot().style()
|
50 |
demo.load(filter_map, [min_price, max_price, boroughs], map)
|
51 |
btn.click(filter_map, [min_price, max_price, boroughs], map)
|
52 |
|