Hello,
I have the following dataframe
"
Data = StringIO(“”“id;status;month
1;Yes;Jan
2;No;Feb
3;No;Feb
4;Yes;Dec
“””)
df = pd.read_csv(Data, sep=“;”)
"
In this data frame, I apply a filter with “multiselect”
container1 = st.container()
allb1 = st.checkbox(“Select All”, key=“chk1”)
if allb1:
sorted_unique_month = sorted(df[‘Month’].unique())
selected_month = container1.multiselect(‘Month(s):’, sorted_unique_mes, sorted_unique_month, key=“Month1”)
df_selected_month = df[df[‘Month’].isin(selected_month)].astype(str)
else:
sorted_unique_month = sorted(df[‘Month’].unique())
selected_month = container1.multiselect(‘Month(s):’, sorted_unique_month, key=“Month2”)
df_selected_month = df[df[‘Month’].isin(selected_month)].astype(str)
So when I select a month, the result is correct:
st.dataframe(df_selected_month)
but when I apply the dataframe resulting from the filter to obtain another result, the dataframe appears empty. Why?
This is the code of the second filter without obtaining the dataframe
days = df_selected_month .loc[df_selected_month .loc[:, ‘status’] == Yes]
st.dataframe(days)
I do not apply another multiselect because I need to filter the data by a status in several dataframes.
Any ideas?