title: Python: pandas merge multiple dataframes
body: <p>I have diferent dataframes and need to merge them together based on the date column. If I only had two dataframes, I could use <code>df1.merge(df2, on='date')</code>, to do it with three dataframes, I use <code>df1.merge(df2.merge(df3, on='date'), on='date')</code>, however it becomes really complex and unreadable to do it with multiple dataframes. </p>
  
  <p>All dataframes have one column in common -<code>date</code>, but they don't have the same number of rows nor columns and I only need those rows in which each date is common to every dataframe.</p>
  
  <p>So, I'm trying to write a recursion function that returns a dataframe with all data but it didn't work. How should I merge multiple dataframes then?</p>
  
  <p>I tried diferent ways and got errors like <code>out of range</code>, <code>keyerror 0/1/2/3</code> and <code>can not merge DataFrame with instance of type &lt;class 'NoneType'&gt;</code>.</p>
  
  <p>This is the script I wrote:</p>
  
  <pre><code>dfs = [df1, df2, df3] # list of dataframes
  
  def mergefiles(dfs, countfiles, i=0):
      if i == (countfiles - 2): # it gets to the second to last and merges it with the last
          return
  
      dfm = dfs[i].merge(mergefiles(dfs[i+1], countfiles, i=i+1), on='date')
      return dfm
  
  print(mergefiles(dfs, len(dfs)))
  </code></pre>
  
  <p>An example:
  df_1:</p>
  
  <pre><code>May 19, 2017;1,200.00;0.1%
  May 18, 2017;1,100.00;0.1%
  May 17, 2017;1,000.00;0.1%
  May 15, 2017;1,901.00;0.1%
  </code></pre>
  
  <p>df_2:</p>
  
  <pre><code>May 20, 2017;2,200.00;1000000;0.2%
  May 18, 2017;2,100.00;1590000;0.2%
  May 16, 2017;2,000.00;1230000;0.2%
  May 15, 2017;2,902.00;1000000;0.2%
  </code></pre>
  
  <p>df_3:</p>
  
  <pre><code>May 21, 2017;3,200.00;2000000;0.3%
  May 17, 2017;3,100.00;2590000;0.3%
  May 16, 2017;3,000.00;2230000;0.3%
  May 15, 2017;3,903.00;2000000;0.3%
  </code></pre>
  
  <p>Expected merge result:</p>
  
  <pre><code>May 15, 2017;  1,901.00;0.1%;  2,902.00;1000000;0.2%;   3,903.00;2000000;0.3%   
  </code></pre>