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)
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.
No what i want is to create col1 that handle a form where inside the form i have subcol1subcol2 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.
I also want the nested columns to design a monitor with multiple panes which contains columns of sub-elements. The solution here did not really solve the issue of nested column layout. Appreciated if anyone knows how to achieve that. Thanks.
I’ve not found a real workaround but you can kind of solve it by using custom HTML elements and st.markdown() to replicate columns for simple elements.
Here is another hack: Nested Columns work fine in most cases. Just uncomment the error in the streamlit code (file PYTHON_PATH\lib\site-packages\streamlit\delta_generator.py line 557ff)
If someone stumbles upon this thread, from version 1.18.0, you can have one level of nested columns in the main area of the app! Check the changelog and the st.columns documentation for details.
import streamlit as st
## Define layout and containers
HEIGHT = 400
cols = st.columns(2)
with cols[0]:
left_panel = st.container(height=HEIGHT + 15, border=True)
with cols[1]:
upper_right_panel = st.container(height=HEIGHT//2, border=True)
lower_right_panel = st.container(height=HEIGHT//2, border=True)
## Add contents
with left_panel:
"## Left panel"
"A bunch of text " * 100
with upper_right_panel:
"## Upper right panel"
"A bunch of text " * 100
with lower_right_panel:
"## Lower panel"
"A bunch of text " * 100
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.