Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,8 @@ class DataList:
|
|
| 42 |
def render(self, search_query: str,
|
| 43 |
filter_names: list[str],
|
| 44 |
filter_names2: list[str],
|
| 45 |
-
filter_names3: list[str],
|
|
|
|
| 46 |
self.table = pd.read_csv(csv_url)
|
| 47 |
self._preprocess_table()
|
| 48 |
|
|
@@ -59,7 +60,7 @@ class DataList:
|
|
| 59 |
df = df[df.name_lowercase.str.contains(search_query.lower())]
|
| 60 |
df1 = self.filter_table1(df, filter_names)
|
| 61 |
df2 = self.filter_table2(df1,filter_names2)
|
| 62 |
-
df3 = self.filter_table3(df2,filter_names3)
|
| 63 |
result = self.to_html(df3, self.table_header)
|
| 64 |
return result
|
| 65 |
|
|
@@ -75,7 +76,9 @@ class DataList:
|
|
| 75 |
return df
|
| 76 |
|
| 77 |
@staticmethod
|
| 78 |
-
def filter_table3(df: pd.DataFrame,filter_names3: list[str]) -> pd.DataFrame:
|
|
|
|
|
|
|
| 79 |
if not filter_names3:
|
| 80 |
return df
|
| 81 |
df.loc[:,'Hashtags'] = df['Hashtags'].fillna("").astype(str);
|
|
@@ -173,7 +176,7 @@ with gr.Blocks(css=css, theme=gr.themes.Default(primary_hue="blue", secondary_hu
|
|
| 173 |
table = gr.HTML(show_label=False)
|
| 174 |
|
| 175 |
demo.load(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,filter_names3,], outputs=[table,])
|
| 176 |
-
search_button.click(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,filter_names3,], outputs=[table,])
|
| 177 |
|
| 178 |
demo.queue()
|
| 179 |
demo.launch(share=False)
|
|
|
|
| 42 |
def render(self, search_query: str,
|
| 43 |
filter_names: list[str],
|
| 44 |
filter_names2: list[str],
|
| 45 |
+
filter_names3: list[str],
|
| 46 |
+
show_filter_checkbox: bool) -> tuple[int, str]:
|
| 47 |
self.table = pd.read_csv(csv_url)
|
| 48 |
self._preprocess_table()
|
| 49 |
|
|
|
|
| 60 |
df = df[df.name_lowercase.str.contains(search_query.lower())]
|
| 61 |
df1 = self.filter_table1(df, filter_names)
|
| 62 |
df2 = self.filter_table2(df1,filter_names2)
|
| 63 |
+
df3 = self.filter_table3(df2,filter_names3,show_filter_checkbox: bool)
|
| 64 |
result = self.to_html(df3, self.table_header)
|
| 65 |
return result
|
| 66 |
|
|
|
|
| 76 |
return df
|
| 77 |
|
| 78 |
@staticmethod
|
| 79 |
+
def filter_table3(df: pd.DataFrame,filter_names3: list[str],show_filter_checkbox: bool) -> pd.DataFrame:
|
| 80 |
+
if not show_filter_checkbox:
|
| 81 |
+
return df
|
| 82 |
if not filter_names3:
|
| 83 |
return df
|
| 84 |
df.loc[:,'Hashtags'] = df['Hashtags'].fillna("").astype(str);
|
|
|
|
| 176 |
table = gr.HTML(show_label=False)
|
| 177 |
|
| 178 |
demo.load(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,filter_names3,], outputs=[table,])
|
| 179 |
+
search_button.click(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,filter_names3,show_filter_checkbox,], outputs=[table,])
|
| 180 |
|
| 181 |
demo.queue()
|
| 182 |
demo.launch(share=False)
|