Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
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 |
|