diff --git a/doc/source/whatsnew/v0.16.1.txt b/doc/source/whatsnew/v0.16.1.txt index bf01d3b21f3fa..576103b5411b5 100644 --- a/doc/source/whatsnew/v0.16.1.txt +++ b/doc/source/whatsnew/v0.16.1.txt @@ -31,3 +31,5 @@ Performance Improvements Bug Fixes ~~~~~~~~~ + +- Bug in ``Series.quantile`` on empty Series of type ``Datetime`` or ``Timedelta`` (:issue:`9675`) diff --git a/pandas/core/series.py b/pandas/core/series.py index 7e3b21be13525..68f3a6032402f 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2095,7 +2095,7 @@ def _maybe_box(self, func, dropna=False): boxer = com.i8_boxer(self) if len(values) == 0: - return boxer(iNaT) + return boxer(tslib.iNaT) values = values.view('i8') result = func(values) diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index ae2ed4eaca2f4..9b5e36974553b 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -6837,6 +6837,11 @@ def test_repeat(self): def test_unique_data_ownership(self): # it works! #1807 Series(Series(["a", "c", "b"]).unique()).sort() + + def test_datetime_timedelta_quantiles(self): + # covers #9694 + self.assertTrue(pd.isnull(Series([],dtype='M8[ns]').quantile(.5))) + self.assertTrue(pd.isnull(Series([],dtype='m8[ns]').quantile(.5))) if __name__ == '__main__': nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],