title: Python: Lookup value in header of another data frame and replace/map the corresponding value
body: <p>I have a data frame with index members which looks like this (A,B,C,... are the company names):</p>
  
  <pre><code>df_members
  
          Date  1  2  3  4
  0 2016-01-01  A  B  C  D
  1 2016-01-02  B  C  D  E
  2 2016-01-03  C  D  E  F
  3 2016-01-04  F  A  B  C
  4 2016-01-05  B  C  D  E
  5 2016-01-06  A  B  C  D
  </code></pre>
  
  <p>and I have a second table including e.g. prices:</p>
  
  <pre><code>df_prices
  
           Date   A   B   C   D   E   F
  0  2015-12-30   1   2   3   4   5   6
  1  2015-12-31   7   8   9  10  11  12
  2  2016-01-01  13  14  15  16  17  18
  3  2016-01-02  20  21  22  23  24  25
  4  2016-01-03  27  28  29  30  31  32
  5  2016-01-04  34  35  36  37  38  39
  6  2016-01-05  41  42  43  44  45  46
  7  2016-01-06  48  49  50  51  52  53
  </code></pre>
  
  <p>The goal is to replace all company names in df1 with the price from df_prices resulting in df_result:</p>
  
  <pre><code>df_result
  
           Date   1   2   3   4 
  0  2016-01-01  13  14  15  16
  1  2016-01-02  21  22  23  24
  2  2016-01-03  29  30  31  32
  3  2016-01-04  39  34  35  36
  4  2016-01-05  42  43  44  45
  5  2016-01-06  48  49  50  51
  </code></pre>
  
  <p>I already have a solution where I iterate through all cells in df_members, look for the values in df_prices and write them in a new data frame df_result. The problem is that my data frames are very large and this process takes around 7 hours.</p>
  
  <p>I already tried to use the merge/join, map or lookup function but it could not solve the problem.</p>
  
  <p>My approach is the following:</p>
  
  <pre><code># Create new dataframes
  df_result = pd.DataFrame(columns=df_members.columns, index=unique_dates_list)
  
  # Load prices
  df_prices = prices
  
  # Search ticker &amp; write values in new dataframe
  for i in range(0,len(df_members)):
      for j in range(0,len(df_members.columns)):
          if str(df_members.iloc[i, j]) != 'nan' and df_members.iloc[i, j] in df_prices.columns:
              df_result.iloc[i, j] = df_prices.iloc[i, df_prices.columns.get_loc(df_members.iloc[i, j])]
  </code></pre>
  
  <p>Question: Is there a way to map the values more efficiently?</p>