Table is note removed after I remove the filter

Summary

Hi,
I´m using a filter from my app
https://aitrade-139addaeee3e.herokuapp.com/#ativos-forex-fx

import streamlit as st
#import streamlit_tags as st
import plotly.express as px
import pandas as pd
import os

#Pickles
import pickle

#https://streamlit-emoji-shortcodes-streamlit-app-gwckff.streamlit.app/
#:bar_chart: :snake: :heavy_dollar_sign: :moneybag: :chart: :floppy_disk: :chart_with_upwards_trend: :pirate_flag: :dark_sunglasses: :rocket: :sunny: :robot_face:
st.set_page_config(page_title=“Guia Trade - AI”, page_icon=“:pirate_flag:”, layout=“wide”)
st.title(“:crystal_ball: Trade com Inteligência Artificial”)
st.markdown(‘div.block-container{padding-top:1rem;}’, unsafe_allow_html=True)

st.markdown(“##”)

hide_streamlit_style = “”"

#MainMenu {visibility: hidden;} header {visibility: hidden;} footer {visibility: hidden;}

“”"
st.markdown(hide_streamlit_style, unsafe_allow_html=True)

#side bar
st.sidebar.image(“logo.png”, caption=“Guia Trade AI”)

Load 1h DF

#---------------------------------------------------------------------------------------------------

#df = load_obj(‘…/Long Short/pickle/dfTradeFinal’) #dictDfFinal
#df = pd.read_pickle(“…/Long Short/dfTradeFinal.pkl”)
df = load_obj(‘dfTradeFinal’)

#caixa de multiseleção
#obs.: utilizando o dataframe criado anteriormente
st.markdown(“### Tabela Inteira”)
cx_mult = st.multiselect(
‘Tabela’,
df.columns,)
#st.dataframe(df[cx_mult], hide_index=True)
if cx_mult:
st.dataframe(df[cx_mult].style.applymap(color_survived), hide_index=True, use_container_width=False)

#---------------------------------------------------------------------------------------------------

Selecione o Filtro

#---------------------------------------------------------------------------------------------------

st.sidebar.header("Selecione o Filtro: ")

Create for Ativo

ativos = st.sidebar.multiselect(“Filtro por Ativo”, df[“symbol”].unique())
if not ativos:
df2 = df.copy()
else:
df2 = df[df[“symbol”].isin(ativos)]
#st.dataframe(df2)

Create for Brasil

brList = [‘USDBRL’,‘Bra50Oct23’,‘PETR4’,‘VALE3’, ‘BBDC4’, ‘ITUB4’,‘BOVA11’,‘WIN-BR’,‘DOLAR-BR’]

ativosbr = st.sidebar.multiselect(“Ativos Brasil (BR)”, df[df[“symbol”].isin(brList)])
if not ativosbr:
df3 = df2.copy()
else:
df3 = df2[df[“symbol”].isin(ativosbr)]

Create for Forex

fxList = [‘EURUSD’,‘EURAUD’,‘EURCAD’,‘EURGBP’,‘EURJPY’,‘EURNZD’,‘GBPUSD’,‘GBPAUD’,‘GBPCAD’,‘GBPJPY’,‘GBPNZD’,‘USDCAD’,‘GER40’,‘XAUUSD’,‘US30’,‘US500’]

ativosfx = st.sidebar.multiselect(“Ativos Forex (FX)”, df[df[“symbol”].isin(fxList)])

Filter the data based on ativos, ativosbr and ativosfx

col1, col2, col3 = st.columns((3))

No Filters

if not ativos and not ativosbr and not ativosfx:
filtered_df = df
pass

All Filters

elif ativos and ativosbr and ativosfx:
# Ativos
filtered_df = df[df[“symbol”].isin(ativos)]
# Ativosbr
filtered_df2 = df[df[“symbol”].isin(ativosbr)]
# AtivosFx
filtered_df3 = df[df[“symbol”].isin(ativosfx)]
# Filter using the first Filter applied to avoid duplicated Symbols if it was selected on first Filter - Ativos -
filtered_df2 = filtered_df2[~filtered_df2[“symbol”].isin(filtered_df[‘symbol’].tolist())]
# Remove Filer from filter 1 if selected
filtered_df3 = filtered_df3[~filtered_df3[“symbol”].isin(filtered_df[‘symbol’].tolist())]

with col1:
    st.subheader("Ativos")
    st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

with col2:
    st.subheader("Ativos Brasil (BR)")
    st.dataframe(filtered_df2.style.applymap(color_survived), hide_index=True)

with col3:
    st.subheader("Ativos Forex (FX)")
    st.dataframe(filtered_df3.style.applymap(color_survived), hide_index=True)

Ativo

elif not ativosbr and not ativosfx:
filtered_df = df[df[“symbol”].isin(ativos)]
with col1:
st.subheader(“Filtro por Ativo”)
st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

Ativobr

elif not ativos and not ativosfx:
filtered_df = df[df[“symbol”].isin(ativosbr)]
with col1:
st.subheader(“Ativos Brasil (BR)”)
st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

Ativobr and Ativofx

elif ativosbr and ativosfx:
#filtered_df = df3[df[“symbol”].isin(ativosbr) & df3[“symbol”].isin(ativosfx)]
filtered_df = df[df[“symbol”].isin(ativosbr)]
filtered_df2 = df[df[“symbol”].isin(ativosfx)]

with col1:
    st.subheader("Ativos Brasil (BR)")
    st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

with col2:
    st.subheader("Ativos Forex (FX)")
    st.dataframe(filtered_df2.style.applymap(color_survived), hide_index=True)

Ativo and Ativofx

elif ativos and ativosfx:
#filtered_df = df3[df[“symbol”].isin(ativos) & df3[“symbol”].isin(ativosfx)]
filtered_df = df[df[“symbol”].isin(ativos)]
filtered_df2 = df[df[“symbol”].isin(ativosfx)]
# Filter using the first Filter applied to avoid duplicated Symbols if it was selected on first Filter - Ativos -
filtered_df2 = filtered_df2[~filtered_df2[“symbol”].isin(filtered_df[‘symbol’].tolist())]

with col1:
    st.subheader("Ativos")
    st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

with col2:
    st.subheader("Ativos Forex (FX)")
    st.dataframe(filtered_df2.style.applymap(color_survived), hide_index=True)

Ativo and Ativobr

elif ativos and ativosbr:

filtered_df = df[df["symbol"].isin(ativos)]
filtered_df2 = df[df["symbol"].isin(ativosbr)]
# Filter using the first Filter applied to avoid duplicated Symbols if it was selected on first Filter - Ativos -
filtered_df2 = filtered_df2[~filtered_df2["symbol"].isin(filtered_df['symbol'].tolist())]

with col1:
    st.subheader("Ativos")
    st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

with col2:
    st.subheader("Ativos Brasil (BR)")
    st.dataframe(filtered_df2.style.applymap(color_survived), hide_index=True)

Ativofx

elif ativosfx:
filtered_df = df[df[“symbol”].isin(ativosfx)]
with col1:
st.subheader(“Ativos Forex (FX)”)
st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

else:
filtered_df = df[df[“symbol”].isin(ativosfx)]

with col1:
    st.subheader("Ativos Forex (FX)")
    st.dataframe(filtered_df.style.applymap(color_survived), hide_index=True)

import time

time.sleep(50)
st.experimental_rerun()

Hi @Dicast

It is unclear what is the problem entered is and how it is expected to be if it is properly working, could you elaborate. Also, it would be helpful to provide a minimum working example that produces the error.

Hi dataprofessor, thanks for answering!.

I have attached a picture of the error, which I think is easier to understand.

To sum up, the error occurs when I delete a filter (left sidebar). the table remains blurry instead of being deleted.

Let me know if you need more details, thanks!