abhicodes commited on
Commit
7cf8289
1 Parent(s): 58a58df

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+ data1 = pd.read_csv('dataset/archive (2)/ball.csv')
5
+ data2 = pd.read_csv('dataset/archive (2)/bat.csv')
6
+
7
+ datasets = {'Bowling Data': pd.DataFrame(data1), 'Batting Data': pd.DataFrame(data2)}
8
+
9
+
10
+ # Function to filter the DataFrame based on user inputs
11
+ def filter_data(dataset_name='', name_x='', name_y='', start_date=''):
12
+ selected_dataset = datasets.get(dataset_name, pd.DataFrame())
13
+ filtered_df = selected_dataset[
14
+ selected_dataset['name_x'].str.contains(name_x, case=False) &
15
+ selected_dataset['name_y'].str.contains(name_y, case=False) &
16
+ selected_dataset['start_date'].str.contains(start_date, case=False)
17
+ ]
18
+ return filtered_df
19
+
20
+
21
+ # Define the input components for the Gradio interface
22
+ dataset_selector = gr.Dropdown(choices=list(datasets.keys()), label='Select Dataset')
23
+ name_x_filter = gr.Textbox(label='Player Name', placeholder='eg. Virat Kohli')
24
+ name_y_filter = gr.Textbox(label='Match Detail', placeholder='eg. India v Australia')
25
+ start_date_filter = gr.Textbox(label='Match Date', placeholder='eg. 2015-10-13')
26
+
27
+ # Create the Gradio interface
28
+ iface = gr.Interface(fn=filter_data, inputs=[dataset_selector, name_x_filter, name_y_filter, start_date_filter], outputs='dataframe')
29
+
30
+ # Launch the interface
31
+ iface.launch()