Gradio Dataframe Update: New Features and Enhancements

Hugging Face has released a significant update to the gr.Dataframe component in Gradio, resolving over 70 issues including bugs, improvements, and enhancements. This update focuses on increasing the utility of dataframes for leaderboards, dashboards, and interactive visualizations by improving data manipulation, navigation, and accessibility.

Data Manipulation and Selection

The updated gr.Dataframe now supports more intuitive data interaction. Users can select multiple cells simultaneously to copy or delete values across a selection. Additionally, the component now supports row and column selection, allowing developers to access entire row data during select events for more streamlined data manipulation.

Key selection improvements include:

  • Multi-Cell Selection: Ability to select, copy, and delete multiple cells at once.
  • Row and Column Selection: Access to full row data in select events.
  • Improved Cell Selection: A smoother and more intuitive cell selection experience.

Navigation and Visibility

To handle wide or large datasets, Gradio has introduced several navigation aids. The pinned_columns parameter allows critical columns to remain in view while scrolling horizontally through wide datasets. A new "Scroll to Top" button has been added to facilitate quick navigation in long lists.

Other visibility features include:

  • Row Numbers: The ability to add row number columns for better data tracking.
  • Full Screen Mode: Enabled via the show_full_screen parameter, this provides a distraction-free interactive view of the data.

Data Discovery and Control

Developers can now implement powerful search and filtering tools directly within the dataframe. By setting the show_search parameter to either "search" or "filter", users can either quickly find specific data points or narrow down the dataset to focus on specific criteria.

Control over the dataframe's interactivity and appearance is also enhanced:

  • Static Columns: The static_columns parameter allows developers to specify columns that are non-editable, ensuring data integrity for specific fields.
  • Copy Button: A new button allows users to copy cell values into a comma-separated format.
  • Styling: A dedicated styler parameter allows for customized visual styling of the dataframe.

Accessibility and Performance

Improved keyboard navigation has been implemented to make the gr.Dataframe component more accessible. Hugging Face intends to continue refining accessibility, performance, and integration in future updates.

Implementation

These features are available in the latest Gradio release and can be installed via pip install --upgrade gradio.

Example implementation of the new parameters:

import gradio as gr

with gr.Blocks() as demo:
    df = gr.Dataframe(
        label="Irish Wildlife",
        show_search="search",
        show_copy_button=True,
        show_fullscreen_button=True,
        show_row_numbers=True,
        pinned_columns=1,
        static_columns=[0],
        column_widths=["300px"]
    )
    demo.launch()

Sources