title: Pandas groupby, sort datetime in columns or take the last (most recent)
body: <p>[I have not found exact answer on that question in those "duplicates", that jezrael suggests.]</p>
  
  <p>I have quite complicated dataframe. I need to group it by 3 columns and then take the most recent (by columns 'date') value in EACH group.</p>
  
  <pre><code>place  customer type  date        sales
  LA        m      a   2018-12-1      1
  LA        m      b   2018-12-1      4
  LA        m      a   2018-12-4      2
  LA        m      b   2018-12-4      5
  LA        m      a   2018-12-3      3
  LA        m      b   2018-12-3      1
  LA        m      a   2018-12-7      4
  LA        m      b   2018-12-7      10
  LA        f      a   2018-12-1      1
  LA        f      b   2018-12-1      1
  LA        f      a   2018-12-4      15
  LA        f      b   2018-12-4      12
  LA        f      a   2018-12-3      31
  LA        f      b   2018-12-3      11
  LA        f      a   2018-12-7      14
  LA        f      b   2018-12-7      40
  NY        m      a   2018-12-1      3
  NY        m      b   2018-12-1      4
  NY        m      a   2018-12-4      1
  NY        m      b   2018-12-4      13
  NY        m      a   2018-12-3      14
  NY        m      b   2018-12-3      8
  NY        m      a   2018-12-7      11
  NY        m      b   2018-12-7      10
  </code></pre>
  
  <p>I need to group df by place, customer and type, and then in each subgroup select most recent date and corresponding sales:</p>
  
  <pre><code>place  customer type  date        sales
  LA        m      a   2018-12-7      4
                   b   2018-12-7      10
            f      a   2018-12-7      40
                   b   2018-12-7      14
  NY        m      a   2018-12-7      11
                   b   2018-12-7      10
  </code></pre>
  
  <p>I tried</p>
  
  <pre><code>gr = df.groupby([df['place'], df['customer'], df['type']]).last()
  </code></pre>
  
  <p>but this gives the last row, which generally speaking is not always the most recent date (dates can be shuffled)</p>