abhicodes's picture
Update app.py
518615e
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()