Variable/Object Scope

Hello Streamlit Community

I have an Issue which make me little crazy it’s about the scope, I will print my example here to make it clear

  if ml_part == '2.1-Algos and Params':
        dataset = pd.read_csv("data//output.csv")
        st.subheader('Check for duplicant rows')
        if st.button('Check'):
            duplicate_rows_df = dataset[dataset.duplicated()]
            st.write("number of duplicate rows: ", duplicate_rows_df.shape[0])
            st.write("Here are the duplicate rows", duplicate_rows_df)
        st.subheader('Click if you want to delete the duplicants rows')
        if st.button('Delete duplicated'):
            dataset.drop_duplicates(inplace=True)
            st.success('Duplicates deleted')
            duplicate_rows_df = dataset[dataset.duplicated()]
            st.write("number of duplicate rows: ", duplicate_rows_df.shape[0])
            st.write("Here are the duplicate rows", duplicate_rows_df)

==> Running this piece of code give this
First button count the duplicated rows and print them
Second button is for delete this duplicates rows and when I print it give that they really get deleted
Third button is for a double check, where we can figure out that nothing has been deleted the dataset object still having the duplicated rows

Thanks in advance!