title: Create a new column based on other columns and a dictionary
body: <p>let's suppose I have a dataframe with at least two columns col1 and col2. Also I have a dictionary of dictionaries, whose keys consist of the values in col1 resp. col2.</p>
  
  <pre><code>import pandas as pd
  dict_of_dicts = {'x0': {'y0':1, 'y1':2, 'y2':3}, 'x1': {'y0':0, 'y1':0,    'y2':1}, 'x2': {'y0':2, 'y1':1, 'y2':3}} 
  df = pd.DataFrame( {'col1': ['x1', 'x2', 'x2'], 'col2': ['y0', 'y1', 'y0']} )
  print(df)
    col1 col2
  0   x1   y0
  1   x2   y1
  2   x2   y0
  </code></pre>
  
  <p>Now I want to create a third column that contains the value of my dictionary with the keys given by col1 and col2 in the respective line. Something like</p>
  
  <pre><code>df['col3'] = dict_of_dicts[df['col1']][df['col2']].
  </code></pre>
  
  <p>The result should look like this:</p>
  
  <pre><code>  col1 col2  col3
  0   x1   y0     0
  1   x2   y1     1
  2   x2   y0     2
  </code></pre>
  
  <p>It should be similar to "map", as explained here <a href="https://stackoverflow.com/questions/24216425/adding-a-new-pandas-column-with-mapped-value-from-a-dictionary">Adding a new pandas column with mapped value from a dictionary</a></p>
  
  <p>But I rely on two columns. Could anybody help me with that, please?</p>
  
  <p>By the way: I actually <strong>don't have to</strong> use a dictionary of dictionaries (as just described). I could also use a table (dataframe) with the one set of keys as index set of the dataframe and the other set of keys as the column names. But also here I don't know how to access a specific "cell" which would be specified by the values in col1 and col2.</p>
  
  <p>I hope my problem is clear.</p>
  
  <p>Thank you, Nadja</p>