title: adding values in new column based on indexes with pandas in python
body: <p>I'm just getting into pandas and I am trying to add a new column to an existing dataframe. </p>
  
  <p>I have two dataframes where the index of one data frame links to a column in another dataframe. Where these values are equal I need to put the value of another column in the source dataframe in a new column of the destination column.</p>
  
  <p>The code section below illustrates what I mean. The commented part is what I need as an output.</p>
  
  <p>I guess I need the <code>.loc[]</code> function.</p>
  
  <p>Another, minor, question: is it bad practice to have a non-unique indexes? </p>
  
  <pre><code>import pandas as pd
  
  d = {'key':['a',  'b', 'c'], 
       'bar':[1, 2, 3]}
  
  d2 = {'key':['a', 'a', 'b'],
        'other_data':['10', '20', '30']}
  
  df = pd.DataFrame(d)
  df2 = pd.DataFrame(data = d2)
  df2 = df2.set_index('key')
  
  print df2
  
  ##    other_data  new_col
  ##key           
  ##a            10   1
  ##a            20   1
  ##b            30   2
  </code></pre>