Remove, avoid empty array,list being viewed

Hi,

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

Hi @Dicast, welcome to the Streamlit community!

I’m not sure I understand your question, could you be more specific? Maybe if you post a code snippet we can see what the issue is.

Best,
Randy

Hi Randy, tks for your reply.

st

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

Yes, I’m still not understanding what your desired output is. If you can post the code you are using, then it will be more helpful.

Hi Randy,

I have posted an image in order to try explain it better,.

thanks in advance!

Basically, I just want to remove those empty lists\array and show what I choose through streamlit´s funcions like:
st.text(), st.write() for example.

Please post your code. Without knowing where the empty lists come from, I can’t tell you how to fix it.

Hello, today I faced the same issue, I was able to resolve it by modifying a list comprehension with a more “classic” for loop.

I have classic loops but still facing this same issue.

Did you manage to remove those empty lists/arrays? Let me know.

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]

1 Like

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.