title: How to update dataframe after read the uploaded file using streamlit and python
body: <p>i want to read file by using <code>file_uploader</code> than i have a function that allow user to update the data in the <strong>uploaded file</strong> than it <strong>save the file</strong> on the desktop after that it <strong>reopen the saved file</strong> and display the updated data.</p>
  <p>What i want is to override the uploaded file in order to display the new dataframe once the user click on <strong>button replace</strong></p>
  <p></p>
  <p>In the image above i want to replace the file <strong>book2.xlsx</strong> by the <strong>updated file</strong> after the user change <strong>cat6</strong> to <strong>cat1</strong></p>
  <h1>code:</h1>
  <pre><code>import pandas as pd
  import streamlit as st 
  
  def main():
      
     
      Activities = [&quot;EDA&quot;,&quot;Plot&quot;,&quot;About&quot;]
      choice = st.sidebar.selectbox(&quot;Select Activity&quot;,Activities)
      
      radio = st.sidebar.radio(label=&quot;&quot;, options=[&quot;Single File&quot;, &quot;Multiple Files&quot;])
      
      df = pd.DataFrame()
      pt1=re.compile(&quot;.csv$&quot;)
      pt2=re.compile(&quot;.xlsx$&quot;)
  
      if radio == &quot;Multiple Files&quot;:
          data = st.sidebar.file_uploader('Multiple Excel files', type=[&quot;csv&quot;,&quot;xlsx&quot;,&quot;xls&quot;], accept_multiple_files=True)
      elif radio==&quot;Single File&quot;:    
          data = st.sidebar.file_uploader(&quot;Upload Dataset&quot;,type=[&quot;csv&quot;,&quot;xlsx&quot;,&quot;xls&quot;])
  
      if data is not None:
          #EDA Page
          if choice ==&quot;EDA&quot;:
              st.subheader(&quot;Exploratiry Data Analysis&quot;)
      
              if radio==&quot;Single File&quot;:
                  if data.type ==&quot;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&quot;:
                      df=pd.read_excel(data)
  
  
  
  #show replace     
  
              if st.checkbox(&quot;replace&quot;):
  
                  mydf = st.dataframe(df)
  
                  columns = st.selectbox(&quot;Select  column&quot;, df.columns)
  
                  old_values = st.multiselect(&quot;Current Values&quot;,list(df[columns].unique()),list(df[columns].unique()))
  
                  with st.form(key='my_form'):
  
                      col1,col2 = st.beta_columns(2)
  
                      st_input = st.number_input if is_numeric_dtype(df[columns]) else st.text_input
  
                      with col1:
  
                          old_val = st_input(&quot;old value&quot;)
  
                      with col2:
  
                          new_val = st_input(&quot;new value&quot;)
  
                      if st.form_submit_button(&quot;Replace&quot;):
  
                          df[columns]=df[columns].replace(old_val,new_val)
  
                          st.success(&quot;{} replace with {} successfully &quot;.format(old_val,new_val))
  
  
                          excel = df.to_excel(r&quot;F:\book2.xlsx&quot;, index = False, header=True,encoding=&quot;utf-8&quot;)
  
                          df =pd.read_excel(r&quot;F:\book2.xlsx&quot;)       
  
                          mydf.add_rows(df)
  </code></pre>