AppwithDataSet / app.py
aneesqumar's picture
Create app.py
9514122 verified
Raw
History Blame Contribute Delete
853 Bytes
import gradio as gr
import pandas as pd
# ---------------------------------
# Load Dataset
# ---------------------------------
def load_iris_data():
try:
df = pd.read_csv("Iris.csv")
return df.head(5)
except Exception as e:
return pd.DataFrame({"Error": [str(e)]})
# ---------------------------------
# Gradio UI
# ---------------------------------
with gr.Blocks() as demo:
gr.Markdown(
"""
# 🌸 Iris Dataset Viewer
Click the button below to display the **first 5 rows** of the dataset.
"""
)
load_button = gr.Button("Show First 5 Rows", variant="primary")
output_table = gr.Dataframe(
label="Iris Dataset (First 5 Rows)",
interactive=False
)
load_button.click(
fn=load_iris_data,
outputs=output_table
)
demo.launch()