KonradSzafer commited on
Commit
b23b4eb
1 Parent(s): a21dcff

simple dataframe

Browse files
Files changed (3) hide show
  1. app.py +32 -0
  2. requirements.txt +1 -0
  3. results.csv +0 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+
4
+
5
+ def filter_data(query: str, df: pd.DataFrame) -> pd.DataFrame:
6
+ if query:
7
+ return df[
8
+ df.apply(
9
+ lambda row: row.astype(str).str.contains(query, case=False).any(),
10
+ axis=1
11
+ )
12
+ ]
13
+ else:
14
+ return df
15
+
16
+
17
+ def main():
18
+ df = pd.read_csv('results.csv')
19
+
20
+ def update_output(query: str) -> pd.DataFrame:
21
+ return filter_data(query, df)
22
+
23
+ with gr.Blocks() as blocks:
24
+ query = gr.Textbox(label='Search')
25
+ output_df = gr.Dataframe(df)
26
+ query.change(fn=update_output, inputs=[query], outputs=[output_df])
27
+
28
+ blocks.launch()
29
+
30
+
31
+ if __name__ == '__main__':
32
+ main()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pandas
results.csv ADDED
The diff for this file is too large to render. See raw diff