title: Python pandas: Combine two dataframes by date index and a common column value
body: <p>There are two dateframes, one is df1, another is df2 as follows:</p>
  
  <p>df1:</p>
  
  <pre><code>               a   b    id
  2010-01-01     1   4    21
  2010-01-01     2   5    22
  2010-01-01     3   6    23
  2010-01-01     4   7    24
  2010-01-02     1   4    21
  2010-01-02     2   5    22
  2010-01-02     3   6    23
  2010-01-02     4   7    24
  2010-01-03     1   4    21
  2010-01-03     2   5    22
  2010-01-03     3   6    23
  2010-01-03     4   7    24
  ...........................
  </code></pre>
  
  <p>df2:</p>
  
  <pre><code>               c   d    id
  2010-01-02     1   4    21
  2010-01-02     2   5    22
  2010-01-02     3   6    23
  2010-01-02     4   7    24
  2010-01-03     1   4    21
  2010-01-03     2   5    22
  2010-01-03     3   6    23
  2010-01-03     4   7    24
  ...........................
  </code></pre>
  
  <p>I want to merge or join two dataframes by common index (please notice that some index in df1 is not in df2) and id, and I expected a joined dataframe as following</p>
  
  <pre><code>               c   d    a   b   id
  2010-01-02     1   4    1   4   21
  2010-01-02     2   5    2   5   22
  2010-01-02     3   6    3   6   23
  2010-01-02     4   7    4   7   24
  2010-01-03     1   4    1   4   21
  2010-01-03     2   5    2   5   22
  2010-01-03     3   6    3   6   23
  2010-01-03     4   7    4    7  24
  </code></pre>
  
  <p>I used the following code</p>
  
  <pre><code> df = df1.join(df2, on = ['id'], how='inner')
  </code></pre>
  
  <p>but that did not work</p>