File size: 1,399 Bytes
7cf8289 48403b8 7cf8289 518615e ede3397 7cf8289 ede3397 7cf8289 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
import pandas as pd
data1 = pd.read_csv('ball.csv')
data2 = pd.read_csv('bat.csv')
datasets = {'Bowling Data': pd.DataFrame(data1), 'Batting Data': pd.DataFrame(data2)}
# Function to filter the DataFrame based on user inputs
def filter_data(dataset_name='', name_x='', name_y='', start_date=''):
selected_dataset = datasets.get(dataset_name, pd.DataFrame())
filtered_df = selected_dataset[
selected_dataset['name_x'].str.contains(name_x, case=False) &
selected_dataset['name_y'].str.contains(name_y, case=False) &
selected_dataset['start_date'].str.contains(start_date, case=False)
]
return filtered_df
title = "Players Performance"
description = "Get the performance of each player in the match."
# Define the input components for the Gradio interface
dataset_selector = gr.Dropdown(choices=list(datasets.keys()), label='Select Dataset')
name_x_filter = gr.Textbox(label='Player Name', placeholder='eg. Virat Kohli')
name_y_filter = gr.Textbox(label='Match Detail', placeholder='eg. India v Australia')
start_date_filter = gr.Textbox(label='Match Date', placeholder='eg. 2015-10-13')
# Create the Gradio interface
iface = gr.Interface(fn=filter_data, inputs=[dataset_selector, name_x_filter, name_y_filter, start_date_filter], outputs='dataframe', title=title, description=description,)
# Launch the interface
iface.launch()
|