title: Merging with empty DataFrame
body: <p>I'm trying to merge a dataframe (<code>df1</code>) with another dataframe (<code>df2</code>) for which <code>df2</code> can potentially be empty. The merge condition is <code>df1.index=df2.z</code> (<code>df1</code> is never empty), but I'm getting the following error.</p>
  
  <p>Is there any way to get this working?</p>
  
  <pre><code>In [31]:
  import pandas as pd
  In [32]:
  df1 = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [1, 2, 3]})
  df2 = pd.DataFrame({'x':[], 'y':[], 'z':[]})
  dfm = pd.merge(df1, df2, how='outer', left_index=True, right_on='z')
  ---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-34-4e9943198dae&gt; in &lt;module&gt;()
  ----&gt; 1 dfmb = pd.merge(df1, df2, how='outer', left_index=True, right_on='z')
  
  /usr/local/lib/python2.7/dist-packages/pandas/tools/merge.pyc in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy)
       37                          right_index=right_index, sort=sort, suffixes=suffixes,
       38                          copy=copy)
  ---&gt; 39     return op.get_result()
       40 if __debug__:
       41     merge.__doc__ = _merge_doc % '\nleft : DataFrame'
  
  /usr/local/lib/python2.7/dist-packages/pandas/tools/merge.pyc in get_result(self)
      185 
      186     def get_result(self):
  --&gt; 187         join_index, left_indexer, right_indexer = self._get_join_info()
      188 
      189         ldata, rdata = self.left._data, self.right._data
  
  /usr/local/lib/python2.7/dist-packages/pandas/tools/merge.pyc in _get_join_info(self)
      277                 join_index = self.left.index.take(left_indexer)
      278             elif self.left_index:
  --&gt; 279                 join_index = self.right.index.take(right_indexer)
      280             else:
      281                 join_index = Index(np.arange(len(left_indexer)))
  
  /usr/local/lib/python2.7/dist-packages/pandas/core/index.pyc in take(self, indexer, axis)
      981 
      982         indexer = com._ensure_platform_int(indexer)
  --&gt; 983         taken = np.array(self).take(indexer)
      984 
      985         # by definition cannot propogate freq
  
  IndexError: cannot do a non-empty take from an empty axes.
  </code></pre>