title: How to merge 2 pandas data frames and update a column with latest value from 2 matched rows?
body: <p>I have 2 pandas data frames which have multiple columns.</p>
  <p>Some rows have same values in all columns except one column which is <code>updated_at</code>.</p>
  <p>I need to merge 2 data frames and consider the latest <code>updated_at</code> value from matched rows. <code>updated_at</code> is a datetime value.</p>
  <p>I found a way to merge data frames but not sure how to use the latest value for <code>updated_at</code> column.</p>
  <pre><code>pd.merge(
      df1,
      df2,
      how=&quot;inner&quot;,
      on=[&quot;column_1&quot;, &quot;column_2&quot;, &quot;column_3&quot;])
  </code></pre>
  <p>Here's sample input for <code>df1</code> and <code>df2</code>.</p>
  <p><strong>df1:</strong></p>
  <pre><code>MRN  Encounter ID First Name Last Name  Birth Date       updated_at 
  1          1234       John       Doe  01/02/1999  04/12/2002 6:00 PM   
  2          2345     Joanne       Lee  04/19/2002  04/19/2002 7:22 PM   
  3          3456  Annabelle     Jones  01/02/2001  04/21/2002 5:00 PM
  </code></pre>
  <p><strong>df2:</strong></p>
  <pre><code>MRN  Encounter ID First Name Last Name  Birth Date       updated_at 
  1          1234       John       Doe  01/02/1999  04/12/2002 5:00 PM   
  2          2345     Joanne       Lee  04/19/2002  04/19/2002 8:22 PM
  </code></pre>
  <p><strong>final_output:</strong></p>
  <pre><code>MRN  Encounter ID First Name Last Name  Birth Date       updated_at 
  1          1234       John       Doe  01/02/1999  04/12/2002 6:00 PM   
  2          2345     Joanne       Lee  04/19/2002  04/19/2002 8:22 PM   
  3          3456  Annabelle     Jones  01/02/2001  04/21/2002 5:00 PM
  </code></pre>
  <p>Notice the <code>updated_at</code> column is having latest value from matched records.</p>