title: Combine dataframes based on a shared key
body: <p>I have a directory that each contains dataframes stored as csv files. Each dataframe has some columns, one of which is a key value which has a partner dataframe somewhere else in the directory (which uses the same key). I am trying to find a way to concatenate the two dataframes based on this key. </p>
  
  <p>Each data-frame broadly looks like this:</p>
  
  <pre><code>----------------------------------------
      my_key | variable 1 | variable 2  
  ----------------------------------------
       A           1             2      
       A           6             5      
       A           7             8     
  </code></pre>
  
  <p>So, the key for this data-frame is A. I am essentially trying to find a way to find the other data-frame where A is the key. What I want to end up with is something like this</p>
  
  <pre><code>---------------------------------------------------------------
      df_key | variable 1 | variable 2 | variable 3 | variable 4
  ---------------------------------------------------------------
       A           1             2           3             4      
       A           5             6           7             8      
       A           9             10          11            12     
  </code></pre>
  
  <p>I had initially thought to store data-frames into two separate data-frame lists, and then do some sort of vlookup type function on the key value between lists. But I'm not sure how to achieve this. Some pseudo-code that will hopefully explain what I'm trying to achieve would be something like:</p>
  
  <pre><code>for df1 in dflist_1:
      for df2 in dflist_2
          if df1[key] == df2[key]
              df1.concatenate(df2)
  </code></pre>
  
  <p>Columns between the two partner dataframes are unique, so there shouldn't be a problem concatenating them.</p>