Spaces:
Running
Running
Commit ·
661eb89
1
Parent(s): b3d7da6
rearrange, add more text stats
Browse files
app.py
CHANGED
|
@@ -98,9 +98,13 @@ def full_report():
|
|
| 98 |
df = cached_report.copy(deep=True)
|
| 99 |
|
| 100 |
total_jumps = int(df['jumps'].sum())
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
df['iso'] = df['iso'].map(alpha_2_map)
|
| 103 |
df['jumps'] = df['jumps'].astype(int)
|
|
|
|
| 104 |
|
| 105 |
country_df = df.groupby(['country', 'iso']).sum().reset_index()
|
| 106 |
country_df = country_df.sort_values(by=['jumps'], ascending=False)
|
|
@@ -127,7 +131,7 @@ def full_report():
|
|
| 127 |
city_df = city_df[city_df['city'] != '(not set)']
|
| 128 |
city_df['city'] = city_df.apply(lambda row: row['city'] + ', ' + row['iso'], axis=1)
|
| 129 |
city_df = city_df[city_df['city'].isin(top_10_cities)].reset_index(drop=True)
|
| 130 |
-
city_df = city_df.sort_values(by=['jumps'], ascending=True)
|
| 131 |
|
| 132 |
avg = px.bar(city_df,
|
| 133 |
y='city', x='jumps', color='day',
|
|
@@ -189,7 +193,7 @@ def full_report():
|
|
| 189 |
trendline_scope='overall',
|
| 190 |
template="plotly_dark")
|
| 191 |
|
| 192 |
-
return f"#
|
| 193 |
|
| 194 |
|
| 195 |
with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
|
|
@@ -197,16 +201,16 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
|
|
| 197 |
total_jumps_label = gr.Markdown("Total Jumps: 0")
|
| 198 |
with gr.Row():
|
| 199 |
map_fig = gr.Plot(label="Map")
|
| 200 |
-
with gr.Row():
|
| 201 |
-
county_map = gr.Plot(label="US Map")
|
| 202 |
-
with gr.Row():
|
| 203 |
-
per_day_plot = gr.Plot(label="Jumps per Day")
|
| 204 |
with gr.Row():
|
| 205 |
jumps_over_time = gr.Plot(label="Jumps Over Time")
|
| 206 |
with gr.Row():
|
| 207 |
total_plot = gr.Plot(label="Top 10 Countries")
|
| 208 |
with gr.Row():
|
| 209 |
avg_plot = gr.Plot(label="Top 10 Cities")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
outputs = [total_jumps_label, total_plot, avg_plot, map_fig, jumps_over_time, county_map, per_day_plot]
|
| 212 |
dep = demo.load(full_report, None, outputs)
|
|
|
|
| 98 |
df = cached_report.copy(deep=True)
|
| 99 |
|
| 100 |
total_jumps = int(df['jumps'].sum())
|
| 101 |
+
unique_countries = df['country'].nunique()
|
| 102 |
+
unique_cities = df['city'].nunique()
|
| 103 |
+
|
| 104 |
+
print(f"Total jumps: {total_jumps}, unique countries: {unique_countries}, unique cities: {unique_cities}")
|
| 105 |
df['iso'] = df['iso'].map(alpha_2_map)
|
| 106 |
df['jumps'] = df['jumps'].astype(int)
|
| 107 |
+
df['city'] = df.apply(lambda row: row['city'] if row['country'] != 'Bermuda' else 'Hamilton', axis=1)
|
| 108 |
|
| 109 |
country_df = df.groupby(['country', 'iso']).sum().reset_index()
|
| 110 |
country_df = country_df.sort_values(by=['jumps'], ascending=False)
|
|
|
|
| 131 |
city_df = city_df[city_df['city'] != '(not set)']
|
| 132 |
city_df['city'] = city_df.apply(lambda row: row['city'] + ', ' + row['iso'], axis=1)
|
| 133 |
city_df = city_df[city_df['city'].isin(top_10_cities)].reset_index(drop=True)
|
| 134 |
+
city_df = city_df.sort_values(by=['day', 'jumps'], ascending=True)
|
| 135 |
|
| 136 |
avg = px.bar(city_df,
|
| 137 |
y='city', x='jumps', color='day',
|
|
|
|
| 193 |
trendline_scope='overall',
|
| 194 |
template="plotly_dark")
|
| 195 |
|
| 196 |
+
return f"# {total_jumps:,} total jumps in {unique_cities:,} cities across {unique_countries:,} countries", total, avg, total_map, jumps_over_time, county_map, per_day_plot
|
| 197 |
|
| 198 |
|
| 199 |
with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
|
|
|
|
| 201 |
total_jumps_label = gr.Markdown("Total Jumps: 0")
|
| 202 |
with gr.Row():
|
| 203 |
map_fig = gr.Plot(label="Map")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
with gr.Row():
|
| 205 |
jumps_over_time = gr.Plot(label="Jumps Over Time")
|
| 206 |
with gr.Row():
|
| 207 |
total_plot = gr.Plot(label="Top 10 Countries")
|
| 208 |
with gr.Row():
|
| 209 |
avg_plot = gr.Plot(label="Top 10 Cities")
|
| 210 |
+
with gr.Row():
|
| 211 |
+
per_day_plot = gr.Plot(label="Jumps per Day")
|
| 212 |
+
with gr.Row():
|
| 213 |
+
county_map = gr.Plot(label="US Map")
|
| 214 |
|
| 215 |
outputs = [total_jumps_label, total_plot, avg_plot, map_fig, jumps_over_time, county_map, per_day_plot]
|
| 216 |
dep = demo.load(full_report, None, outputs)
|