How do I create a column in dataframe that takes in manual user input?

I want to have a dataframe with columns that are editable, in particular, the last column should be named “manual entry” where user can key in free text.

I got as far as this in the prototype function below. But the text input button is not embedded in the column of the table itself. I have also heard of streamlit-aggrid but did not try yet, appreciate any help.

import streamlit as st
import pandas as pd

@st.cache
def convert_df(df):
    return df.to_csv().encode("utf-8")

def prototype_2():
    columns = ["A", "B", "C", "manual entry"]
    df = pd.DataFrame(
        data=[
            [1, 2, 3, st.text_input("row1")],
            [4, 5, 6, st.text_input("row2")],
        ],
        columns=columns,
    )
    show_df = st.dataframe(df)

    csv = convert_df(df)

    st.download_button(
        "Press to Download", csv, "file.csv", "text/csv", key="download-csv"
    )


if __name__ == "__main__":
    # prototype_1()
    prototype_2()

Hi @reighns92 , please refer to the AGgrid responses on this forum. You could pass your dataframe into the grid and then use that for editing.

Hope this works for you.

Cheers

Thanks @Shawn_Pereira , could you kindly link me to such post, one post I read is How to add records to a dataframe using python and streamlit - #6 by Shawn_Pereira

Hi @reighns92 ,

Here’s an article that should help you with details:

Here’s the thread on the forum:

Cheers

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.