Show realtime data using dataframe

my question is based on this question.

i want to display realtime data using dataframe

this data is fetched from api

i want to know where should i write st.write(df)
so that dataframe which is displayed in browser gets updated

i tried to write st.write(df) in on_tick function, but it creates new dataframe everytime

and when i write st.write(df) outside on_tick function, dataframe displayed on browser wont get updated

how to solve this issue?

This appears to be answered via: