DontPlanToEnd
commited on
Commit
•
90bf7b7
1
Parent(s):
eee2dcf
Update app.py
Browse files
app.py
CHANGED
@@ -20,28 +20,27 @@ def load_leaderboard_data(csv_file_path):
|
|
20 |
return pd.DataFrame(columns=UGI_COLS) # Return an empty dataframe with the correct columns
|
21 |
|
22 |
# Update the leaderboard table based on the search query and parameter range filters
|
23 |
-
def update_table(df: pd.DataFrame, query: str, param_ranges:
|
24 |
filtered_df = df
|
25 |
-
if any(param_ranges
|
26 |
conditions = []
|
27 |
-
for param_range
|
28 |
-
if
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
conditions.append((filtered_df['Params'] >= 60))
|
45 |
|
46 |
if conditions:
|
47 |
filtered_df = filtered_df[pd.concat(conditions, axis=1).any(axis=1)]
|
@@ -110,13 +109,13 @@ with GraInter:
|
|
110 |
outputs = leaderboard_table
|
111 |
|
112 |
search_bar.change(
|
113 |
-
fn=lambda query, param_ranges: update_table(leaderboard_df, query,
|
114 |
inputs=inputs,
|
115 |
outputs=outputs
|
116 |
)
|
117 |
|
118 |
filter_columns_size.change(
|
119 |
-
fn=lambda query, param_ranges: update_table(leaderboard_df, query,
|
120 |
inputs=inputs,
|
121 |
outputs=outputs
|
122 |
)
|
|
|
20 |
return pd.DataFrame(columns=UGI_COLS) # Return an empty dataframe with the correct columns
|
21 |
|
22 |
# Update the leaderboard table based on the search query and parameter range filters
|
23 |
+
def update_table(df: pd.DataFrame, query: str, param_ranges: list) -> pd.DataFrame:
|
24 |
filtered_df = df
|
25 |
+
if any(param_ranges):
|
26 |
conditions = []
|
27 |
+
for param_range in param_ranges:
|
28 |
+
if param_range == '~1.5':
|
29 |
+
conditions.append((filtered_df['Params'] < 2.5))
|
30 |
+
elif param_range == '~3':
|
31 |
+
conditions.append(((filtered_df['Params'] >= 2.5) & (filtered_df['Params'] < 6)))
|
32 |
+
elif param_range == '~7':
|
33 |
+
conditions.append(((filtered_df['Params'] >= 6) & (filtered_df['Params'] < 9.5)))
|
34 |
+
elif param_range == '~13':
|
35 |
+
conditions.append(((filtered_df['Params'] >= 9.5) & (filtered_df['Params'] < 16)))
|
36 |
+
elif param_range == '~20':
|
37 |
+
conditions.append(((filtered_df['Params'] >= 16) & (filtered_df['Params'] < 28)))
|
38 |
+
elif param_range == '~34':
|
39 |
+
conditions.append(((filtered_df['Params'] >= 28) & (filtered_df['Params'] < 40)))
|
40 |
+
elif param_range == '~50':
|
41 |
+
conditions.append(((filtered_df['Params'] >= 40) & (filtered_df['Params'] < 60)))
|
42 |
+
elif param_range == '~70+':
|
43 |
+
conditions.append((filtered_df['Params'] >= 60))
|
|
|
44 |
|
45 |
if conditions:
|
46 |
filtered_df = filtered_df[pd.concat(conditions, axis=1).any(axis=1)]
|
|
|
109 |
outputs = leaderboard_table
|
110 |
|
111 |
search_bar.change(
|
112 |
+
fn=lambda query, param_ranges: update_table(leaderboard_df, query, param_ranges),
|
113 |
inputs=inputs,
|
114 |
outputs=outputs
|
115 |
)
|
116 |
|
117 |
filter_columns_size.change(
|
118 |
+
fn=lambda query, param_ranges: update_table(leaderboard_df, query, param_ranges),
|
119 |
inputs=inputs,
|
120 |
outputs=outputs
|
121 |
)
|