FDSRashid commited on
Commit
0d7cef9
·
1 Parent(s): 7f9027d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -14,18 +14,21 @@ cities = taraf_info['City'].unique().tolist()
14
  min_year = int(taraf_info['Year'].min())
15
  max_year = int(taraf_info['Year'].max())
16
 
17
- def subset_city_year( city , year ):
18
- edges = taraf_info[(taraf_info['Year'] == year) & (taraf_info['City'].isin(city))]
19
- return edges
20
 
21
  def subset_year(year = 50):
22
  edges = taraf_info[(taraf_info['Year'] == year)]
23
  return edges
24
 
25
- def get_narrators(city, year ):
 
26
  df = subset_city_year(city, year)
27
  narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
28
  return narrators['Edge_Name'].reset_index().drop('index', axis = 1).rename(columns = {'Edge_Name': 'Teacher To Student'})
 
 
29
 
30
 
31
 
@@ -35,4 +38,4 @@ with gr.Blocks() as demo:
35
  Last_Year = gr.Slider(min_year, max_year, value = 50, label = 'End', info = 'Choose the year to display Narrators')
36
  btn = gr.Button('Submit')
37
  btn.click(fn = get_narrators, inputs = [Places, Last_Year], outputs = gr.DataFrame())
38
- demo.launch()
 
14
  min_year = int(taraf_info['Year'].min())
15
  max_year = int(taraf_info['Year'].max())
16
 
17
+ def subset_city_year(city, year):
18
+ edges = taraf_info[(taraf_info['Year'] == year) & (taraf_info['City'].isin(city))]
19
+ return edges
20
 
21
  def subset_year(year = 50):
22
  edges = taraf_info[(taraf_info['Year'] == year)]
23
  return edges
24
 
25
+ def get_narrators( city , year):
26
+ try:
27
  df = subset_city_year(city, year)
28
  narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
29
  return narrators['Edge_Name'].reset_index().drop('index', axis = 1).rename(columns = {'Edge_Name': 'Teacher To Student'})
30
+ except Exception as e:
31
+ return str(e)
32
 
33
 
34
 
 
38
  Last_Year = gr.Slider(min_year, max_year, value = 50, label = 'End', info = 'Choose the year to display Narrators')
39
  btn = gr.Button('Submit')
40
  btn.click(fn = get_narrators, inputs = [Places, Last_Year], outputs = gr.DataFrame())
41
+ demo.launch()