title: "Check for duplicates" error when I am trying to sort dataframe by datetime64
body: <p>I am trying to sort a dataframe by date like this :</p>
  
  <pre><code>result = result.sort_values(by=result.CF_FACT_DATFACT, ascending=True)
  </code></pre>
  
  <p><strong>CF_FACT_DATFACT</strong> is a datetime64.
   by executing this command I have this error : </p>
  
  <blockquote>
    <p>KeyError                                  Traceback (most recent call
    last)  in ()
    ----> 1 result = result.sort_values(by=result.CF_FACT_DATFACT, ascending=True)# group bills by client sort ascending by date of bill</p>
    
    <p>/home/houssem/.local/lib/python2.7/site-packages/pandas/core/frame.pyc
    in sort_values(self, by, axis, ascending, inplace, kind, na_position) 
    4717     4718             by = by[0]
    -> 4719             k = self._get_label_or_level_values(by, axis=axis)    4720     4721             if isinstance(ascending, (tuple, list)):</p>
    
    <p>/home/houssem/.local/lib/python2.7/site-packages/pandas/core/generic.pyc
    in _get_label_or_level_values(self, key, axis)    1704<br>
    values = self.axes[axis].get_level_values(key)._values    1705<br>
    else:
    -> 1706             raise KeyError(key)    1707     1708         # Check for duplicates</p>
    
    <p>KeyError: 0         2015-08-24 1         2016-04-01 2<br>
    2017-04-24 3         2017-03-10 4         2017-05-12 5<br>
    2018-02-02 6         2018-02-03 7         2018-03-04 8<br>
    2018-03-05 9         2018-03-07 10        2018-02-08 11<br>
    2018-04-12 12        2019-04-02 13        2019-04-03 14<br>
    2019-02-07 15        2019-03-09 16        2007-04-06 17<br>
    2007-03-07 18        2007-02-11 19        2007-04-12 20<br>
    2009-04-08 21        2010-05-01 22        2010-02-03 23<br>
    2010-03-08 24        2011-03-01 25        2011-02-12 26<br>
    2012-04-06 27        2012-03-07 28        2012-04-12 29<br>
    2013-04-02
                 ...     3617565   2010-04-10 3617566   2010-04-10 3617567   2011-08-02 3617568   2011-08-02 3617569   2011-08-06 3617570<br>
    2011-08-06 3617571   2011-06-10 3617572   2011-06-10 3617573<br>
    2012-05-30 3617574   2012-05-30 3617575   2012-01-10 3617576<br>
    2012-01-10 3617577   2013-05-30 3617578   2013-05-30 3617579<br>
    2013-09-27 3617580   2013-09-27 3617581   2014-01-30 3617582<br>
    2014-01-30 3617583   2015-03-02 3617584   2015-03-02 3617585<br>
    2009-03-07 3617586   2009-03-07 3617587   2013-06-02 3617588<br>
    2013-06-02 3617589   2014-05-27 3617590   2014-05-27 3617591<br>
    2014-09-25 3617592   2014-09-25 3617593   2016-02-02 3617594<br>
    2016-02-02 Name: CF_FACT_DATFACT, Length: 3617595, dtype:
    datetime64[ns]</p>
  </blockquote>
  
  <p>I don't understand the problem, is the duplicated values raise errors when sorting a dataframe?</p>