title: Trying to merge 2 dataframes in pandas based on multiindex
body: <p>I'm trying to merge 2 dataframes and currently the values for the 2nd dataframe are being appended on the bottom of the first one when I want it included as an additional column. </p>
  
  <p>1st dataframe</p>
  
  <pre><code>┌──────────┬────────────┬────────────────────┬───────────────────────┬─────────┬────────────────┬────────────┬─────────────────────┬────────────────────┬─────────────────┬────────────────────┬───────────┬──────────────┬────────────────┬───────────────────┬───────────┬────────────┬───────┐
  │ filename │    date    │   txVolume(USD)    │ adjustedTxVolume(USD) │ txCount │ marketcap(USD) │ price(USD) │ exchangeVolume(USD) │        fees        │ activeAddresses │ medianTxValue(USD) │ medianFee │ paymentCount │ generatedCoins │ averageDifficulty │ blockSize │ blockCount │ value │
  ├──────────┼────────────┼────────────────────┼───────────────────────┼─────────┼────────────────┼────────────┼─────────────────────┼────────────────────┼─────────────────┼────────────────────┼───────────┼──────────────┼────────────────┼───────────────────┼───────────┼────────────┼───────┤
  │ ada      │ 2017-10-01 │ 436003334.53699994 │         131165286.735 │  3096.0 │            0.0 │   0.021678 │          50068700.0 │         291.170785 │          5973.0 │       18065.296266 │   0.17107 │       1661.0 │                │                   │           │            │       │
  │ ada      │ 2017-10-02 │      1025157737.96 │          151391424.74 │  2943.0 │            0.0 │   0.024607 │          57641300.0 │ 316.07460299999997 │          5858.0 │ 24206.767144999998 │   0.17107 │       1792.0 │                │                   │           │            │       │
  │ ada      │ 2017-10-03 │       604612406.44 │         125245327.846 │  1808.0 │    624650688.0 │   0.025757 │          16997800.0 │ 182.28098300000002 │          3701.0 │ 21063.743716900004 │   0.17107 │       1018.0 │                │                   │           │            │       │
  └──────────┴────────────┴────────────────────┴───────────────────────┴─────────┴────────────────┴────────────┴─────────────────────┴────────────────────┴─────────────────┴────────────────────┴───────────┴──────────────┴────────────────┴───────────────────┴───────────┴────────────┴───────┘
  </code></pre>
  
  <p>2nd dataframe:</p>
  
  <pre><code>┌──────────┬────────────┬─────────────────────────────────┐
  │ filename │    date    │ monthly percentage price change │
  ├──────────┼────────────┼─────────────────────────────────┤
  │ ada      │ 2017-10-31 │                                 │
  │ ada      │ 2017-11-30 │              2.3253932111955717 │
  │ ada      │ 2017-12-31 │               5.768998209206785 │
  │ ada      │ 2018-01-31 │            -0.17893930881865483 │
  └──────────┴────────────┴─────────────────────────────────┘
  </code></pre>
  
  <p>I want to include the 'monthly % price column' on the end of a consolidated dataframe based on the keys: 'filename' and 'date'.  Below is the code I've written to get to this point.  I'm still a complete newbie so I apologise in advance for my badly written code:</p>
  
  <pre><code># get data file names
  path =r'C:\Users\david\Documents\Crypto\Crypto_historical_data'
  filenames = glob.glob(path + "/*.csv")
  
  # Create a list called 'data':
  data = []
  # Include filename as a column in the dataframe
  for csv in filenames:
      frame = pd.read_csv(csv)
      #frame['filename'] creates a new column named filename
      # os.path.basename() turns a path like /a/d/c.txt into the filename c.txt
      frame['filename'] = os.path.splitext(os.path.basename(csv))[0]
      data.append(frame)
  
  # Load all data in to the dataframe
  df = pd.concat(data, sort=False)
  
  # Filter out any rows where price is blank
  df1 = df.dropna(subset=['price(USD)'])
  df1 = pd.DataFrame(data=df1)
  df1 = df1.set_index(['filename', 'date'], inplace=False)
  
  # You now have all prices sorted by date &amp; by currency
  
  
  # Exclude ctxc and ven as they are &lt; 6 months old
  df1 = df1.query('filename != ["ctxc", "ven"]')
  
  
  
  # Get end of month prices
  # Sets date as DateTime format:
  df1 = df1.reset_index()
  df1['date'] = pd.to_datetime(df1['date'])
  # Sets date column as the index
  # Groups data by each coin
  # Converts daily to monthly prices, taking last price of the month
  df2 = df1.set_index('date').groupby('filename').resample('M')['price(USD)'].last()
  
  
  # Calculate monthly returns for each coin
  df2 = df2.pct_change()
  df2 = pd.DataFrame(data=df2)
  df2 = df2.rename(columns = {'price(USD)':'monthly percentage price change'})
  
  
  # Merge monthly returns in to df1
  
  df3 = pd.merge(df1, df2, left_index=True, right_index=True,how='outer')
  </code></pre>
  
  <p>When trying to merge I get the error:
  "ValueError: cannot join with no level specified and no overlapping names"</p>
  
  <p>I'm hoping someone can tell me the most efficient way to add the monthly percentage change column on the end of the dataframe, using 'filename' and 'date' as the keys, ensuring that I don't lose any data from the 1st dataframe.  Thanks in advance to anyone that can help me - I've been pulling my hair out over this!</p>