On button click removing elements or replacing it with updated ones

I have a list which is changing its value based on user input/actions and have dataframes displaying objects from that list, I’m not able to remove first ones before a new one are created below. After that it stops, it only creates df’s 2 times and after that just changing the newest one, which is what I want, but without first one. First one keeps staying on top. Any suggestions?

Hi @mict0 - welcome to Streamlit!

I’d love to help here, but I’m having trouble understanding your issue. Do you mind posting your code (or a sample that demonstrates the same problem), so that we can take a look?

Thanks!
Tim

Hey, thanks.
Let me refraze my question. Is it possible to hide dataframe or any other element on button click?

Yes, that’s possible! Here’s a simple example. Note that I’m using an st.checkbox instead of st.button to hide the dataframe, because a checkbox’s value persists between reruns of your app, whereas a button’s value is only True on the first rerun after the button is clicked.

import streamlit as st
import pandas as pd

placeholder = st.empty()
if not st.checkbox("Hide dataframe"):
    df = pd.DataFrame(range(0, 10))
    placeholder.dataframe(df)

If you press the “Hide dataframe” checkbox, the dataframe will disappear (because it simply won’t be drawn when the app re-runs).