Create nested columns

how to create columns inside columns ?

col1_repl, col2_repl = st.columns(2)
col1,col2 = col1_repl.columns(2)
with col1_repl:
        with st.form(key='my_form_non_empty'):
                        
            st_input = st.number_input if is_numeric_dtype(df[columns]) else st.text_input
                        
             with col1:
                  # do something
             with col2:

this display the below error :
StreamlitAPIException: Columns may not be nested inside other columns.

Traceback:
File “f:\AIenv\streamlit\app2.py”, line 1332, in
main()
File “f:\AIenv\streamlit\app2.py”, line 682, in main
col1,col2 = col1_repl.columns(2)

Hi @leb_dev,

Currently, you can’t create columns inside columns, that’s what the error message is saying.

If you want to create a big column next to 2 smaller columns then you can create unevenly sized columns from the first call like so:

col1,col2,col3 = st.columns([2,1,1]) 

This will make col1 twice the size of col2 and col3, effectively being the exact same visually as if you created 2 columns that you then split one in half.

Checkout the docs for more on columns.

Happy Streamlit-ing!
Marisa

No what i want is to create
col1 that handle a form where inside the form i have subcol1 subcol2
Col2 have a form with 1 text input and button.

All of this because i want to create a form that allow user to change the values of a field in dataframe
But i had the problem when the user need to replace the NAN values.
Because of that i tried to create this layout nested layout.

So is there another way to being able to replace the selected values and NAN values in the same form this will be very good for me.

Thank you for your reply and help.

Hey

So you want people to be able to edit from your app the data in the dataframe you have changing NAN values to different ones?

You can do this with @ash2shukla component: streamlit-brokeh-events

This post might help: Editable data tables for float values - #3 by blob123

Happy Streamlit-ing!
Marisa