title: Pandas: create a column by mapping from a dict of lists
body: <p>I have a pandas dataframe and a dict as shown below. I would like to create a new column in the dataframe based on in which list from the dict the index of the row is appearing.</p>
  <pre><code>df = pd.DataFrame({
      'a':['x', 'y', 'z'],
      'b':[1, 2, 3],
      'c':[10, 20, 30],
  })
  df = df.set_index('a')
  mydict = {
      'g1':['a', 'b', 'y'],
      'g2':['x', 'k', 'l'],
      'g3':['m', 'l', 'z'],
  }
  </code></pre>
  <p><strong>Expected output</strong></p>
  <pre><code>   b   c   g
  a       
  x  1  10  g2
  y  2  20  g1
  z  3  30  g3
  </code></pre>
  <p>I don't even know how to begin solving this. May be create a custom function and map using that? But will that be performant enough? In my actual use case, there may be hundreds of thousands of rows in 'df' and around hundred keys in 'mydict' and each list will contain tens of thousands of items. Also, I will mostly be dealing with integers instead of strings as shown here.</p>