Introducing Gradio Clients

Watch

New to Gradio? Start here: Getting Started

See the Release History

Dataframe

gradio.Dataframe(ยทยทยท)
import gradio as gr with gr.Blocks() as demo: gr.Dataframe(value= [ [0, 1, True], [1, 0, False] ] , interactive=True) demo.launch()

Description

This component displays a table of value spreadsheet-like component. Can be used to display data as an output component, or as an input to collect data from the user.

Behavior

As input component: Passes the uploaded spreadsheet data as a pandas.DataFrame, numpy.array, polars.DataFrame, or native 2D Python list[list] depending on type

Your function should accept one of these types:
def predict(
	value: pd.DataFrame | np.ndarray | pl.DataFrame | list[list]
)
	...

As output component: Expects data any of these formats: pandas.DataFrame, pandas.Styler, numpy.array, polars.DataFrame, list[list], list, or a dict with keys 'data' (and optionally 'headers'), or str path to a csv, which is rendered as the spreadsheet.

Your function should return one of these types:
def predict(ยทยทยท) -> pd.DataFrame | Styler | np.ndarray | pl.DataFrame | list | list[list] | dict | str | None
	...	
	return value

Initialization

Parameters

Shortcuts

Class Interface String Shortcut Initialization

gradio.Dataframe

"dataframe"

Uses default values

gradio.Numpy

"numpy"

Uses type="numpy"

gradio.Matrix

"matrix"

Uses type="array"

gradio.List

"list"

Uses type="array", col_count=1

Demos

import gradio as gr def filter_records(records, gender): return records[records["gender"] == gender] demo = gr.Interface( filter_records, [ gr.Dataframe( headers=["name", "age", "gender"], datatype=["str", "number", "str"], row_count=5, col_count=(3, "fixed"), ), gr.Dropdown(["M", "F", "O"]), ], "dataframe", description="Enter gender as 'M', 'F', or 'O' for other.", ) if __name__ == "__main__": demo.launch()

Event Listeners

Description

Event listeners allow you to respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.

Supported Event Listeners

The Dataframe component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Parameters table below.

Listener Description

Dataframe.change(fn, ยทยทยท)

Triggered when the value of the Dataframe changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.

Dataframe.input(fn, ยทยทยท)

This listener is triggered when the user changes the value of the Dataframe.

Dataframe.select(fn, ยทยทยท)

Event listener for when the user selects or deselects the Dataframe. Uses event data gradio.SelectData to carry value referring to the label of the Dataframe, and selected to refer to state of the Dataframe. See EventData documentation on how to use this event data

Event Parameters

Parameters