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.