Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,12 +4,7 @@ import plotly.graph_objects as go
|
|
4 |
from datasets import load_dataset
|
5 |
|
6 |
dataset = load_dataset('text', data_files={'train': ['NPI_2023_01_17-05.10.57.PM.csv'], 'test': 'NPI_2023_01_17-05.10.57.PM.csv'})
|
7 |
-
|
8 |
#1.6GB NPI file with MH therapy taxonomy provider codes (NUCC based) with human friendly replacement labels (e.g. Counselor rather than code)
|
9 |
-
#datasetNPIMH = load_dataset("awacke1/NPI-Providers-And-Facilities-By-Taxonomy", split="train")
|
10 |
-
#datasetNPIMH = load_dataset("awacke1/NPI-Providers-And-Facilities-By-Taxonomy", split='train[:1%]')
|
11 |
-
#print(datasetNPIMH.shape)
|
12 |
-
|
13 |
datasetNYC = load_dataset("gradio/NYC-Airbnb-Open-Data", split="train")
|
14 |
df = datasetNYC.to_pandas()
|
15 |
|
@@ -24,15 +19,14 @@ def getDatasetFind(findString):
|
|
24 |
finder = dataset['train'].filter(lambda example: example['text'].find(findString))
|
25 |
finder = finder = finder.to_pandas()
|
26 |
g1=MatchText(finder, findString)
|
27 |
-
|
28 |
return g1
|
29 |
|
30 |
def filter_map(min_price, max_price, boroughs):
|
31 |
-
|
32 |
filtered_df = df[(df['neighbourhood_group'].isin(boroughs)) & (df['price'] > min_price) & (df['price'] < max_price)]
|
33 |
names = filtered_df["name"].tolist()
|
34 |
prices = filtered_df["price"].tolist()
|
35 |
text_list = [(names[i], prices[i]) for i in range(0, len(names))]
|
|
|
36 |
fig = go.Figure(go.Scattermapbox(
|
37 |
customdata=text_list,
|
38 |
lat=filtered_df['latitude'].tolist(),
|
@@ -58,11 +52,48 @@ def filter_map(min_price, max_price, boroughs):
|
|
58 |
zoom=9
|
59 |
),
|
60 |
)
|
|
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
return fig
|
63 |
|
|
|
64 |
with gr.Blocks() as demo:
|
65 |
with gr.Column():
|
|
|
|
|
66 |
with gr.Row():
|
67 |
min_price = gr.Number(value=250, label="Minimum Price")
|
68 |
max_price = gr.Number(value=1000, label="Maximum Price")
|
@@ -70,16 +101,30 @@ with gr.Blocks() as demo:
|
|
70 |
btn = gr.Button(value="Update Filter")
|
71 |
map = gr.Plot().style()
|
72 |
|
|
|
73 |
with gr.Row():
|
74 |
-
df20 = gr.Textbox(lines=4, default="", label="Find
|
75 |
btn2 = gr.Button(value="Find")
|
76 |
-
#df21 = gr.Textbox(lines=4, default="", label="Found:")
|
77 |
with gr.Row():
|
78 |
df4 = gr.Dataframe(wrap=True, max_rows=10000, overflow_row_behaviour= "paginate")
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
demo.load(filter_map, [min_price, max_price, boroughs], map)
|
81 |
-
btn.click(filter_map, [min_price, max_price, boroughs], map)
|
82 |
|
|
|
83 |
btn2.click(getDatasetFind,df20,df4 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
demo.launch()
|
|
|
4 |
from datasets import load_dataset
|
5 |
|
6 |
dataset = load_dataset('text', data_files={'train': ['NPI_2023_01_17-05.10.57.PM.csv'], 'test': 'NPI_2023_01_17-05.10.57.PM.csv'})
|
|
|
7 |
#1.6GB NPI file with MH therapy taxonomy provider codes (NUCC based) with human friendly replacement labels (e.g. Counselor rather than code)
|
|
|
|
|
|
|
|
|
8 |
datasetNYC = load_dataset("gradio/NYC-Airbnb-Open-Data", split="train")
|
9 |
df = datasetNYC.to_pandas()
|
10 |
|
|
|
19 |
finder = dataset['train'].filter(lambda example: example['text'].find(findString))
|
20 |
finder = finder = finder.to_pandas()
|
21 |
g1=MatchText(finder, findString)
|
|
|
22 |
return g1
|
23 |
|
24 |
def filter_map(min_price, max_price, boroughs):
|
|
|
25 |
filtered_df = df[(df['neighbourhood_group'].isin(boroughs)) & (df['price'] > min_price) & (df['price'] < max_price)]
|
26 |
names = filtered_df["name"].tolist()
|
27 |
prices = filtered_df["price"].tolist()
|
28 |
text_list = [(names[i], prices[i]) for i in range(0, len(names))]
|
29 |
+
|
30 |
fig = go.Figure(go.Scattermapbox(
|
31 |
customdata=text_list,
|
32 |
lat=filtered_df['latitude'].tolist(),
|
|
|
52 |
zoom=9
|
53 |
),
|
54 |
)
|
55 |
+
return fig
|
56 |
|
57 |
+
def centerMap(min_price, max_price, boroughs):
|
58 |
+
filtered_df = df[(df['neighbourhood_group'].isin(boroughs)) & (df['price'] > min_price) & (df['price'] < max_price)]
|
59 |
+
names = filtered_df["name"].tolist()
|
60 |
+
prices = filtered_df["price"].tolist()
|
61 |
+
text_list = [(names[i], prices[i]) for i in range(0, len(names))]
|
62 |
+
|
63 |
+
latitude = 44.9382
|
64 |
+
longitude = -93.6561
|
65 |
+
|
66 |
+
fig = go.Figure(go.Scattermapbox(
|
67 |
+
customdata=text_list,
|
68 |
+
lat=filtered_df['latitude'].tolist(),
|
69 |
+
lon=filtered_df['longitude'].tolist(), mode='markers',
|
70 |
+
marker=go.scattermapbox.Marker(
|
71 |
+
size=6
|
72 |
+
),
|
73 |
+
hoverinfo="text",
|
74 |
+
#hovertemplate='Lat: %{lat} Long:%{lng} City: %{cityNm}'
|
75 |
+
))
|
76 |
+
|
77 |
+
fig.update_layout(
|
78 |
+
mapbox_style="open-street-map",
|
79 |
+
hovermode='closest',
|
80 |
+
mapbox=dict(
|
81 |
+
bearing=0,
|
82 |
+
center=go.layout.mapbox.Center(
|
83 |
+
lat=latitude,
|
84 |
+
lon=longitude
|
85 |
+
),
|
86 |
+
pitch=0,
|
87 |
+
zoom=9
|
88 |
+
),
|
89 |
+
)
|
90 |
return fig
|
91 |
|
92 |
+
|
93 |
with gr.Blocks() as demo:
|
94 |
with gr.Column():
|
95 |
+
|
96 |
+
# Price/Boroughs/Map/Filter for AirBnB
|
97 |
with gr.Row():
|
98 |
min_price = gr.Number(value=250, label="Minimum Price")
|
99 |
max_price = gr.Number(value=1000, label="Maximum Price")
|
|
|
101 |
btn = gr.Button(value="Update Filter")
|
102 |
map = gr.Plot().style()
|
103 |
|
104 |
+
# Mental Health Provider Finder
|
105 |
with gr.Row():
|
106 |
+
df20 = gr.Textbox(lines=4, default="", label="Find Mental Health Provider e.g. City/State/Name/License:")
|
107 |
btn2 = gr.Button(value="Find")
|
|
|
108 |
with gr.Row():
|
109 |
df4 = gr.Dataframe(wrap=True, max_rows=10000, overflow_row_behaviour= "paginate")
|
110 |
|
111 |
+
# City Map
|
112 |
+
with gr.Row():
|
113 |
+
df2 = gr.Textbox(lines=1, default="Mound", label="Find City:")
|
114 |
+
latitudeUI = gr.Textbox(lines=1, default="44.9382", label="Latitude:")
|
115 |
+
longitudeUI = gr.Textbox(lines=1, default="-93.6561", label="Longitude:")
|
116 |
+
btn3 = gr.Button(value="Lat-Long")
|
117 |
+
|
118 |
demo.load(filter_map, [min_price, max_price, boroughs], map)
|
|
|
119 |
|
120 |
+
btn.click(filter_map, [min_price, max_price, boroughs], map)
|
121 |
btn2.click(getDatasetFind,df20,df4 )
|
122 |
+
# Lookup on US once you have city to get lat/long
|
123 |
+
# US 55364 Mound Minnesota MN Hennepin 053 44.9382 -93.6561 4
|
124 |
+
#latitude = 44.9382
|
125 |
+
#longitude = -93.6561
|
126 |
+
#btn3.click(centerMap, map)
|
127 |
+
|
128 |
+
btn3.click(centerMap, [min_price, max_price, boroughs], map)
|
129 |
|
130 |
demo.launch()
|