Skip to main content
The Dataframe component displays and edits tabular data in a spreadsheet format.

Basic usage

import gradio as gr
import pandas as pd

def process_data(df):
    return df.describe()

gr.Interface(
    fn=process_data,
    inputs=gr.Dataframe(),
    outputs=gr.Dataframe()
).launch()

Constructor

value
pd.DataFrame | np.ndarray | list | dict | str | Callable | None
default:"None"
Default data. Accepts pandas DataFrame, numpy array, list of lists, dict, or CSV filepath
headers
list[str] | None
default:"None"
Column headers. If None, headers are inferred from data
row_count
int | None
default:"None"
Initial number of rows to display
column_count
int | None
default:"None"
Initial number of columns. Defaults based on data
datatype
str | Sequence[str]
default:"'str'"
Column datatypes. Can be:
  • Single string: "str", "number", "bool", "date", "markdown"
  • List per column: ["str", "number", "bool"]
  • "auto" - Automatically infer types
type
Literal['pandas', 'numpy', 'array', 'polars']
default:"'pandas'"
Format passed to function:
  • "pandas" - pandas DataFrame
  • "numpy" - numpy array
  • "array" - Python list of lists
  • "polars" - Polars DataFrame
interactive
bool | None
default:"None"
Whether users can edit the dataframe
max_height
int | str
default:"500"
Maximum height with scrollbar if needed
wrap
bool
default:"False"
Whether text in cells should wrap
line_breaks
bool
default:"True"
Enable line breaks in markdown cells

Events

  • change - Triggered when data changes
  • input - Triggered on input
  • select - Triggered when cell is selected
  • edit - Triggered when cell is edited

Examples

With pandas

import gradio as gr
import pandas as pd

df = pd.DataFrame({
    "Name": ["Alice", "Bob"],
    "Age": [25, 30],
    "City": ["NYC", "LA"]
})

gr.Dataframe(value=df, interactive=True)

With specific datatypes

import gradio as gr

gr.Dataframe(
    headers=["Name", "Score", "Passed"],
    datatype=["str", "number", "bool"],
    row_count=3
)