title: pandas - check changes in dataframe
body: <p>I'm aware of <a href="https://stackoverflow.com/questions/17095101/outputting-difference-in-two-pandas-dataframes-side-by-side-highlighting-the-d">this</a> question, and I've been working through it. I have two dataframes <code>df1</code> and <code>df2</code> which look like:</p>
  
  <p><strong>df1</strong>:</p>
  
  <pre><code>U,T,L,P
  01,string1,a,0.9
  02,string2,b,0.9
  03,string3,c,0.9
  </code></pre>
  
  <p><strong>df2</strong>:</p>
  
  <pre><code>U,T,L,P
  01,string1,a,0.9
  02,string2,d,0.9
  03,string3,c,0.9
  </code></pre>
  
  <p>Basically the only difference is in the <code>L</code> column and in the second row, where <code>b</code> becomes <code>d</code>. I would like to check this difference comparing the dataframes, keeping all the existing information. Following the above question, my attempts so far have been:</p>
  
  <pre><code>difference_locations = np.where(df1 != df2)
  
  changed_from = df1.values[difference_locations]
  
  changed_to = df2.values[difference_locations]
  
  a = pd.DataFrame({'from': changed_from, 'to': changed_to})
  </code></pre>
  
  <p>which returns:</p>
  
  <pre><code>  from to
  0    b  d
  </code></pre>
  
  <p>The result is ok, but I would like to add also the remaining information about the initial datasets. The only changes occur in the columns <code>L</code> and <code>P</code>, and I would highlight the changes so that the result:</p>
  
  <pre><code>  U  T       from to
  0 02 string2    b  d
  </code></pre>
  
  <p>I tried to build the dataframe adding the existing columns with something like:</p>
  
  <pre><code>a = pd.DataFrame({'U': df1['U'],'from': changed_from, 'to': changed_to})
  </code></pre>
  
  <p>but of course it doesn't work since I should perform a lookup over the index to get the right values of <code>U</code> and <code>T</code> in correspondence of the changed row.</p>