zhwang4ai commited on
Commit
c8f6405
·
1 Parent(s): 8a0123e
Files changed (1) hide show
  1. app.py +30 -6
app.py CHANGED
@@ -98,9 +98,33 @@ detailed_success_rate_df = prep_detailed_success_rate_df()
98
  detailed_action_counts_df = prep_detailed_action_counts_df()
99
 
100
  # Function to update the table based on search query
101
- def filter_and_search(cols: list[str], search_query: str, df, agg: str,):
102
  # print("filter")
103
- df = df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  search_terms = "Model"
105
  if len(search_query) > 0:
106
  search_terms = search_query.split(";")
@@ -164,8 +188,8 @@ with demo:
164
  wrap=True,
165
  column_widths=[350, 120] + [(150 + len(c)) for c in detailed_success_rate_df.columns[2:]],
166
  )
167
- cols_bar.change(filter_and_search, inputs=[cols_bar, search_bar, detailed_success_rate_table], outputs=[detailed_success_rate_table])
168
- search_bar.submit(filter_and_search, inputs=[cols_bar, search_bar, detailed_success_rate_table], outputs=[detailed_success_rate_table])
169
 
170
  with gr.TabItem("Action Counts - Detailed"):
171
  with gr.Column():
@@ -183,8 +207,8 @@ with demo:
183
  wrap=True,
184
  column_widths=[350, 120] + [(100 + len(c)) for c in detailed_action_counts_df.columns[2:]],
185
  )
186
- cols_bar_1.change(filter_and_search, inputs=[cols_bar_1, search_bar_1, detailed_action_counts_table], outputs=[detailed_action_counts_table])
187
- search_bar_1.submit(filter_and_search, inputs=[cols_bar_1, search_bar_1, detailed_action_counts_table], outputs=[detailed_action_counts_table])
188
 
189
  with gr.TabItem("About"):
190
  gr.Markdown(ABOUT)
 
98
  detailed_action_counts_df = prep_detailed_action_counts_df()
99
 
100
  # Function to update the table based on search query
101
+ def filter_and_search_success_rate(cols: list[str], search_query: str, agg: str,):
102
  # print("filter")
103
+ df = detailed_success_rate_df
104
+ search_terms = "Model"
105
+ if len(search_query) > 0:
106
+ search_terms = search_query.split(";")
107
+ search_terms = [term.strip().lower() for term in search_terms]
108
+ pattern = "|".join(search_terms)
109
+ df = df[df["Model"].str.lower().str.contains(pattern, regex=True)]
110
+ # Drop any columns which are all NaN
111
+ df = df.dropna(how="all", axis=1)
112
+
113
+ if len(cols) > 0:
114
+ index_cols = list(leaderboard_df.columns[:1])
115
+ new_cols = index_cols + cols
116
+ df = df.copy()[new_cols]
117
+ df = df.copy().dropna(how="all", axis=0, subset=[c for c in df.columns if c in cols])
118
+
119
+ df[cols] = df[cols].apply(pd.to_numeric, errors='coerce')
120
+ df = df.sort_values(by=cols, ascending=False, na_position='last')
121
+ df[cols] = df[cols].astype(str)
122
+ return df
123
+
124
+ # Function to update the table based on search query
125
+ def filter_and_search_action_counts(cols: list[str], search_query: str, agg: str,):
126
+ # print("filter")
127
+ df = detailed_action_counts_df
128
  search_terms = "Model"
129
  if len(search_query) > 0:
130
  search_terms = search_query.split(";")
 
188
  wrap=True,
189
  column_widths=[350, 120] + [(150 + len(c)) for c in detailed_success_rate_df.columns[2:]],
190
  )
191
+ cols_bar.change(filter_and_search_success_rate, inputs=[cols_bar, search_bar], outputs=[detailed_success_rate_table])
192
+ search_bar.submit(filter_and_search_success_rate, inputs=[cols_bar, search_bar], outputs=[detailed_success_rate_table])
193
 
194
  with gr.TabItem("Action Counts - Detailed"):
195
  with gr.Column():
 
207
  wrap=True,
208
  column_widths=[350, 120] + [(100 + len(c)) for c in detailed_action_counts_df.columns[2:]],
209
  )
210
+ cols_bar_1.change(filter_and_search_action_counts, inputs=[cols_bar_1, search_bar_1], outputs=[detailed_action_counts_table])
211
+ search_bar_1.submit(filter_and_search_action_counts, inputs=[cols_bar_1, search_bar_1], outputs=[detailed_action_counts_table])
212
 
213
  with gr.TabItem("About"):
214
  gr.Markdown(ABOUT)