awacke1 commited on
Commit
88daa75
·
1 Parent(s): 32cdbc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -4
app.py CHANGED
@@ -3,13 +3,33 @@ import pandas as pd
3
  import plotly.graph_objects as go
4
  from datasets import load_dataset
5
 
6
- dataset = load_dataset("gradio/NYC-Airbnb-Open-Data", split="train")
7
- df = dataset.to_pandas()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  def filter_map(min_price, max_price, boroughs):
10
 
11
- filtered_df = df[(df['neighbourhood_group'].isin(boroughs)) &
12
- (df['price'] > min_price) & (df['price'] < max_price)]
13
  names = filtered_df["name"].tolist()
14
  prices = filtered_df["price"].tolist()
15
  text_list = [(names[i], prices[i]) for i in range(0, len(names))]
@@ -49,7 +69,17 @@ with gr.Blocks() as demo:
49
  boroughs = gr.CheckboxGroup(choices=["Queens", "Brooklyn", "Manhattan", "Bronx", "Staten Island"], value=["Queens", "Brooklyn"], label="Select Boroughs:")
50
  btn = gr.Button(value="Update Filter")
51
  map = gr.Plot().style()
 
 
 
 
 
 
 
 
52
  demo.load(filter_map, [min_price, max_price, boroughs], map)
53
  btn.click(filter_map, [min_price, max_price, boroughs], map)
 
 
54
 
55
  demo.launch()
 
3
  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
+
16
+ def MatchText(pddf, name):
17
+ pd.set_option("display.max_rows", None)
18
+ data = pddf
19
+ swith=data.loc[data['text'].str.contains(name, case=False, na=False)]
20
+ return swith
21
+
22
+ def getDatasetFind(findString):
23
+ #finder = dataset.filter(lambda example: example['text'].find(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))]
 
69
  boroughs = gr.CheckboxGroup(choices=["Queens", "Brooklyn", "Manhattan", "Bronx", "Staten Island"], value=["Queens", "Brooklyn"], label="Select Boroughs:")
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 Text:")
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()