title: Big data in pandas, matching and backfilling/forwardfilled one table based on another table
body: <p>I have a dataframe df_original which is huge (10 million rows). The index is date (multiple same dates), and there are 20 rows, but the one of interest here is Company. Company may/may not be available for every date. The data goes back 10 years.</p>
  
  <p>Eg of df_original:    </p>
  
  <pre><code>           Company
  1/24/2007   Astec
  1/24/2007   Abra
  1/24/2007   Apple
  1/24/2007   Acle ltd
  1/24/2007   Apple ent
  1/24/2007   Aztrazenca
  1/24/2007   Alpha ltd
  1/24/2007   Altit ltd
  1/24/2007   Blackberry
  1/24/2007   Burberry
  1/24/2007   Blue ltd
  1/24/2007   Bluefin
  1/25/2017   Abra
  1/25/2017   Apple
  1/25/2017   Acle ltd
  1/25/2017   Aztrazenca
  1/25/2017   Altit ltd
  1/25/2017   Blackberry
  1/25/2017   Burberry
  1/25/2017   Blue ltd
  1/25/2017   Bluefin
  </code></pre>
  
  <p>Now I have another table which looks like this (in practise it is much larger). It is the dates when a companies grade changes (not daily frequency, just whenever it changes):</p>
  
  <p>df_grade_changes:</p>
  
  <pre><code>            Date    Company Grade
  2/2/2017    Abra        D
  2/1/2017    Blue ltd    B
  1/21/2017   Blue fin    C
  1/1/2017    Aztrazenca  B
  12/10/2016  Altit ltd   A
  11/29/2016  Blackberry  C
  11/18/2016  Abra        B
  11/6/2016   Blue ltd    A
  </code></pre>
  
  <p>I want to add a row in df_original, which has the Grade of each company for each day using df_grade_changes as a source.</p>
  
  <p>Ie, Whenever the Grade changes for a company it to be reflected from that day on wards in df_original. The key thing is that Grades change over time not on a daily manner in df_grade_changes.</p>
  
  <p>Using df_grade_changesin the above example Abra from 11/18/2016 to 1 day before 2/2/2017 would have grade B, for which it will be D after indefinitely unless it arrives at another grade change. So I believe it may have to work from oldest to newest or newest to oldest.</p>
  
  <p>Help would be appreciated.</p>