Spaces:
Sleeping
Sleeping
File size: 1,121 Bytes
f1d0d9d |
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 |
import gradio as gr
import pandas as pd
import plotly.express as px
# Define the function to load the CSV file
def load_data(file):
df = pd.read_csv(file)
return df
# Create the input interface for the CSV file
inputs = gr.inputs.UploadButton(label="Upload your CSV file:")
# Define the main function that will be called when the user submits their file
def main(inputs):
df = load_data(inputs)
return df
# Create the output interface for the DataFrame
outputs = gr.outputs.Dataframe(examples={"file1.csv": "path/to/file1.csv",
"file2.csv": "path/to/file2.csv",
"file3.csv": "path/to/file3.csv"})
# Create the Plot output interface
plot = gr.outputs.Plotly(click_submit_button=True)
# Define the plot function that will be called when the user selects their options
def plot_function(df, x, y):
fig = px.scatter(df, x=x, y=y)
return fig
# Create the Gradio interface
interface = gr.Interface(fn=main, inputs=inputs, outputs=outputs, title="CSV Plotter", plot=plot, plot_fn=plot_function)
interface.launch() |