title: Dropping column during for loop - Pandas
body: <p>I have two basic DataFrames, and I combine them into a list called dfCombo:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  df = pd.DataFrame(np.arange(12).reshape(3,4), columns=['A', 'B', 'C', 'D'])
  df2 = pd.DataFrame(np.arange(12,24).reshape(3,4), columns=['A', 'B', 'C', 'D'])
  dfCombo = [df, df2]
  </code></pre>
  
  <p>They are both 3x4 DF's with 4 columns A, B, C, D.</p>
  
  <p>I am able to use a for loop to add a column to both the DF with the following code:</p>
  
  <pre><code>for df3 in dfCombo:
      df3['E'] = df3['A'] + df3['B']
  </code></pre>
  
  <p>With this both df and df2 will both have an new column E. However when I try to drop a column using this method with the below code, no columns are dropped:</p>
  
  <pre><code>for df3 in dfCombo:
      df3 = df3.drop('B', axis = 1)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>for df3 in dfCombo:
      df3 = df3.drop(columns = ['B'])
  </code></pre>
  
  <p>If I use the same code on a single DF the column is dropped:</p>
  
  <pre><code>df2 = df2.drop('B', axis = 1)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>df2 = df2.drop(columns = ['B'])
  </code></pre>
  
  <p>If you could help me understand what is going on I would be most appreciative.</p>