FDSRashid commited on
Commit
d74f67f
·
verified ·
1 Parent(s): 4489131

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -25,12 +25,13 @@ max_year = int(taraf_s['Year'].max())
25
  def plot_timeline(yaxis, citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
26
  if min_year >= max_year:
27
  raise gr.error('Min Year Cannot be Bigger than Max Year!')
28
- if citi == ['All']:
29
- filtered = taraf_s.copy()[(taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)].groupby(['Year']).sum().reset_index()
30
- fig = px.line(data_frame = filtered, x = 'Year', y = yaxis, title = f"{yaxis} per Year", color = 'City', template = 'plotly_dark' )
31
- else:
32
- filtered = taraf_s[taraf_s['City'].isin(citi) & (taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)]
33
- fig = px.line(data_frame = filtered, x = 'Year', y = yaxis, title = f"{yaxis} per Year", color = 'City', template = 'plotly_dark' )
 
34
  fig.update_layout(legend_x=1, legend_y=0, title = {'x':.5})
35
  return fig
36
 
 
25
  def plot_timeline(yaxis, citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
26
  if min_year >= max_year:
27
  raise gr.error('Min Year Cannot be Bigger than Max Year!')
28
+
29
+ filtered = taraf_s[taraf_s['City'].isin(citi) & (taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)].drop(['Unnamed: 0', 'Ranking'], axis = 1)
30
+ if 'All' in citi:
31
+ tot = taraf_s.groupby(['Year']).sum().reset_index().drop(['Unnamed: 0', 'Ranking'], axis = 1)
32
+ tot['City'] = 'All'
33
+ filtered = pd.concat([filtered, tot])
34
+ fig = px.line(data_frame = filtered, x = 'Year', y = yaxis, title = f"{yaxis} per Year", color = 'City', template = 'plotly_dark' )
35
  fig.update_layout(legend_x=1, legend_y=0, title = {'x':.5})
36
  return fig
37