User input for column in dataframe using Ag-Grid

Hi, anyone can help me on how to create user input column names in a dataframe. Currently I’m using Ag-Grid library for streamlit. The code is:

    if 'num' not in st.session_state:
        st.session_state.num = 1
    numrow = st.number_input("Number of row", min_value=0, max_value=50)
    numcol = st.number_input("Number of Column", min_value=1, max_value=50)
    col = []
    num = st.session_state.num

    col_name = st.text_input("Column Name", key=num)

    for i in range(int(numcol)):

    df_template = pd.DataFrame(
        **columns= list(col_name)**

    with st.form('dataset') as f:
        st.header('Your dataset')
        response = AgGrid(df_template, editable=True, fit_columns_on_grid_load=True)


Output is as in image captured.
![Screenshot from 2022-08-10 15-59-06|513x499](upload://w6VmuZdsctETveIzCpwopkmZYSF.png)

I want user to be able to insert their column name. Can someone help me to solve this? Thanks in advance!

the output image…

Hi again @hazirafidi :wave:

Since you are using columns= list(col_name), to define the columns. I’m guessing it treats every character as a column name. To get column names based on the input no. of columns, I think you can use the method mentioned in this (Iterate dictionary in streamlit) to get column names one by one and store them in a list and add it to the data frame as columns and use it for the AgGrid.

Hope this helps :v:.