Change/input data into multiple cells from the data_editor table at once

Hi all, pretty simple question here. Is it possible to change multiple cells in the data_editor table at once? I would like to select a rectangular area of the table (by clicking and dragging the selection), and then input one value and have it replicate it automatically throughout all the selected cells. When I try to do this, it only updates the originally selected cell before dragging.

Here is a simple example of the data_editor (for example, I would like to select all 4 cells in this table, and change all of them to the value “2” at the same time):

import pandas as pd
import streamlit as st
df = pd.DataFrame()
df.loc['row1', 'col1'] = 1
df.loc['row1', 'col2'] = 1
df.loc['row2', 'col1'] = 1
df.loc['row2', 'col2'] = 1
edited_df = st.data_editor(df)

Thank you

I don’t know of a way to select first, then enter in all cells. However, you can enter the value in one cell then click and drag (once for each orthogonal direction) to propagate the change.

2024-12-09_21-24-31 (1)

Thank you @mathcatsand. That would be my second option. It feels like nitpicking a little bit but I think it would make the user experience much better.

Feel free to submit a feature request on GitHub. :slight_smile: GitHub issues is the primary place where devs track user interest in features.

1 Like