FDSRashid commited on
Commit
e95d2c0
·
1 Parent(s): 0a85c61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -13,19 +13,22 @@ taraf_info = dataset2.to_pandas()
13
  cities = taraf_info['City'].unique().tolist()
14
 
15
  def subset_city_year( city , year ):
16
- edges = taraf_info[(taraf_info['Year'] == year) & (taraf_info['City'].isin(city))]
17
- return edges
18
 
19
 
20
 
21
  def get_narrators( city , year ):
22
- df = subset_city_year(city, year)
23
- narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
24
- return narrators['Edge_Name'].reset_index().rename(columns = {'Edge_Name': 'Teacher To Student'})
 
 
 
25
 
26
  app = gr.Interface(get_narrators,
27
  [gr.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
28
  gr.Slider(-11,800, value = 50, label = 'Year', info = 'Choose The Year to Retrieve Narrators'),
29
  ],
30
- 'dataframe').launch()
31
 
 
13
  cities = taraf_info['City'].unique().tolist()
14
 
15
  def subset_city_year( city , year ):
16
+ edges = taraf_info[(taraf_info['Year'] == year) & (taraf_info['City'].isin(city))]
17
+ return edges
18
 
19
 
20
 
21
  def get_narrators( city , year ):
22
+ try:
23
+ df = subset_city_year(city, year)
24
+ narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
25
+ return narrators['Edge_Name'].reset_index().rename(columns = {'Edge_Name': 'Teacher To Student'})
26
+ except Exception as e:
27
+ return str(e)
28
 
29
  app = gr.Interface(get_narrators,
30
  [gr.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
31
  gr.Slider(-11,800, value = 50, label = 'Year', info = 'Choose The Year to Retrieve Narrators'),
32
  ],
33
+ 'dataframe', live = True).launch()
34