Editable Data Tables in Streamlit

Hey @sheridonx, thanks for checking out Streamlit, and for the kind words!

Editable data tables don’t currently exist in Streamlit. You can approximate them somewhat by using st.text_input and st.number_input to allow the user to enter values that you write back into your dataframe, like in this contrived example:

import streamlit as st
import numpy as np
import pandas as pd

# Randomly fill a dataframe and cache it
@st.cache(allow_output_mutation=True)
def get_dataframe():
    return pd.DataFrame(
        np.random.randn(50, 20),
        columns=('col %d' % i for i in range(20)))


df = get_dataframe()

# Create row, column, and value inputs
row = st.number_input('row', max_value=df.shape[0])
col = st.number_input('column', max_value=df.shape[1])
value = st.number_input('value')

# Change the entry at (row, col) to the given value
df.values[row][col] = value

# And display the result!
st.dataframe(df)

But I imagine you’re after a more spreadsheet-like interface, where the user just directly edits the “cell” they’re interested in.

We don’t currently have this feature on the roadmap, but have been giving it some thought in a GitHub issue. If you’re interested, please feel free to upvote the issue and/or participate in the discussion!

3 Likes