Spaces:
Sleeping
Sleeping
File size: 853 Bytes
9514122 | 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 36 37 38 | 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()
|