title: How to merge two dataframes on a timeseries
body: <p>What I am looking to create is a dataframe which looks like:</p>
  
  <pre><code>    amount  months      category    
  0   6460    2018-01-31  budgeted    
  1   7905    2018-01-31  actual  
  2   11509   2018-02-28  budgeted    
  3   21502   2018-02-28  actual 
  ...
  ...
  </code></pre>
  
  <p>The sample code I have and base datafrom I am working with is:</p>
  
  <pre><code>import pandas as pd
  import string
  import altair as alt
  
  from random import randint
  
  # 
  # This is the general form of my 'real' dataframe. It is not subject to change.
  #
  months                  = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
  monthyAmounts           = [ "actual", "budgeted", "difference" ]
  
  summary = []
  
  summary.append( [ randint( -1000, 15000 ) for x in range( 0, len( months ) * len( monthyAmounts ) ) ] )
  summary.append( [ randint( -1000, 15000 ) for x in range( 0, len( months ) * len( monthyAmounts ) ) ]  )
  summary.append( [ randint( -1000, 15000 ) for x in range( 0, len( months ) * len( monthyAmounts ) ) ]  )
  
  index   = pd.Index( [ 'Income', 'Expenses', 'Difference' ], name = 'type' )
  columns = pd.MultiIndex.from_product( [months, monthyAmounts], names=['month', 'category'] )
  
  summaryDF = pd.DataFrame( summary, index = index, columns = columns )
  
  #
  # From this point, I am trying to transform the summaryDF into something 
  # I can use in a different context...
  #
  
  budgetMonths = pd.date_range( "January, 2018", periods = 12, freq = 'BM' )
  
  idx = pd.IndexSlice
  budgeted = summaryDF.loc[ 'Difference', idx[:, 'budgeted' ] ].cumsum()
  actual   = summaryDF.loc[ 'Difference', idx[:, 'actual' ] ].cumsum()
  
  budgeted.index = budgetMonths
  actual.index = budgetMonths
  
  budgetedDF = pd.DataFrame( { 'amount': budgeted, 'months': budgetMonths, 'category': 'budgeted' })
  actualDF   = pd.DataFrame( { 'amount': actual, 'months': budgetMonths, 'category': 'actual' })
  
  print( budgetedDF )
  print( actualDF )
  
  df3 = pd.merge( budgetedDF, actualDF, on = 'months' )
  df3 
  </code></pre>
  
  <p>df3 looks like:</p>
  
  <pre><code>    amount_x    months      category_x  amount_y    category_y
  0   6460        2018-01-31  budgeted    7905        actual
  1   11509       2018-02-28  budgeted    21502       actual
  ...
  ...
  </code></pre>
  
  <p>I think I am close to getting what I want...just need the final merge step.</p>