title: Subtracting one dataframe column from another dataframe column for multiple columns
body: <p>I'm trying to subtract a column from one dataframe from another dataframe's column, and I wanted to do it for n number of columns (currently the dataframes I'm working on have 1000 columns). </p>
  
  <p>Here are how the two dataframes look like:</p>
  
  <p><strong>Dataframe 1:</strong></p>
  
  <pre><code>               branch A (pkg XYZ) | branch A (pkg ABC)| branch B (pkg XYZ)
                 -------------------------------------------------------------
  5/21 - 5/27           20          |        30         |        50
  5/28 - 6/02           10          |        30         |        50
  6/03 - 6/09           30          |        40         |        50
  6/10 - 6/16           20          |        30         |        50
  6/17 - 6/23           50          |        10         |        50
  </code></pre>
  
  <p><strong>Dataframe 2:</strong></p>
  
  <pre><code>                branch A (pkg XYZ)| branch A (pkg ABC) | branch B (pkg XYZ)
                  -----------------------------------------------------------
  5/21 - 5/27           3           |        5           |        50
  5/28 - 6/02           2           |        6           |        50
  6/03 - 6/09           3           |        7           |        50
  6/10 - 6/16           1           |        2           |        50
  6/17 - 6/23           4           |        0           |        50
  </code></pre>
  
  <p>If I wanted to subtract all the columns of <strong>Dataframe 2</strong> from <strong>Dataframe 1</strong>, based on if their column headers ("<em>branch A (pkg XYZ)</em>") match, what would be the most efficient way of doing this?</p>
  
  <p>I tried iterating through a list of one dataframes columns and subtracting it from the other dataframe that way, but it seems inefficient. </p>
  
  <pre><code>  i = 0
    df1_cols = list(df1)
    while i &lt; len(df1.columns):
         col_name = df1_cols[i]
  
         # df3 is an empty dataframe
         df3[col_name] = df1[col_name] - df2[col_name]
  
         i += 1
  </code></pre>