title: Rename columns in PANDAS based on dictionary
body: <p>I have a dataframe and I would like to rename the columns based on another dataframe that I plan to use as dictionary. For example, what I have as first dataframe is:</p>
  
  <pre><code>          AAA   BBB   CCC   DDD
   index   
    1       1     2     3     4
    2       5     6     7     8
  </code></pre>
  
  <p>and as a second dataframe that I would like to use as dictionary:</p>
  
  <pre><code>           val1    val2
    index
      1      AAA      A7
      2      BBB      B0
      3      CCC      C3
      4      DDD      D1
  </code></pre>
  
  <p>What I would like to get as result is the following:</p>
  
  <pre><code>          A7    B0    C3    D1 
   index   
    1       1     2     3     4
    2       5     6     7     8
  </code></pre>
  
  <p>Initially I thought to reshape the first dataframe to long format, then merge with the dictionary dataframe and then reshape back to wide format. However I think this is quite inefficient, so I would like to use a more efficient way (if one exists). Thank you very much four your help. </p>