I’m new using nice tool - streamlit and I would like to know how to avoid empty array or list be viewed.
I’m creating some pandas tables wich I can show without any problem with st.write() …
however, before the table, I see "empty " list with null values.
I have 12 like:
[…]
[
0:NULL
1:NULL
2:NULL
3:NULL
4:NULL
5:NULL
6:NULL
7:NULL
8:NULL
]
No idea why it appears if I do not have any st.func() for example.
Any help or guide is very appreciated - Thanks
I have uploaded an image. I think, it is easier, thereby, you can see the list/array empty being showed.
First func in my code related to streamlit, is st.title(‘Starting at:’,time), but, you can see some list before it. Also, after before next streamlit func which would be: st.write() with may pandas table “Dole”.
I´m running for loops without function, I think the interaction could be logged on streamlit through those lists… Just let me know if you need more details, please.
Thanks
As mentioned above, the fastest way to tell you where the issue is would be to post the code. This isn’t a weird quirk of Streamlit, but likely a tiny logic error.
I had the same problem. After reading randyzwitch’s answer I played around with my function and I found that it was displaying the output of a list comprehension. Even though the list comprehension is inside a function and wouldn’t display as an output in my IDE.
xlistnodup =[ ]
[xlistnodup.append(x) for x in xlist if x not in xlistnodup]
return xlistnodup
creating a place for the output to land solved the problem.
x = [xlistnodup.append(x) for x in xlist if x not in xlistnodup]
This is expected behavior. Streamlit renders most objects that exist on a line by themself by default. This includes a list, even if that list is defined through list comprehension.
I had the same problem. After reading randyzwitch’s answer I played around with my function and I found that it was displaying the output of a list comprehension. Even though the list comprehension is inside a function and wouldn’t display as an output in my IDE.
xlistnodup = [ ]
[xlistnodup.append(x) for x in xlist if x not in xlistnodup]
return xlistnodup
x = [xlistnodup.append(x) for x in xlist if x not in xlistnodup]
creating a place for the output to land solved the problem.
I followed this resolution and managed to resolve the issue.
Basically streamlit prints the output of the list comprehension.
I had the same problem. After reading randyzwitch’s answer I played around with my function and I found that it was displaying the output of a list comprehension. Even though the list comprehension is inside a function and wouldn’t display as an output in my IDE.
xlistnodup = [ ]
[xlistnodup.append(x) for x in xlist if x not in xlistnodup]
return xlistnodup
creating a place for the output to land solved the problem.
x = [xlistnodup.append(x) for x in xlist if x not in xlistnodup]
…
I followed this resolution and managed to resolve the issue.
Basically streamlit prints the output of the list comprehension.
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.