Skip to content

Commit a477202

Browse files
Sam Zhangjreback
Sam Zhang
authored andcommitted
BUG: datetime/timedelta Series quantile() call
Changes to be committed: modified: pandas/core/series.py modified: pandas/tests/test_series.py Fixes global reference to iNaT (should be tslib.iNaT) in series._maybe_box. Adds test `test_datetime_timedelta_quantiles` to check for proper return value in test_series.py. Issue #9675
1 parent beb0812 commit a477202

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

doc/source/whatsnew/v0.16.1.txt

+13
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,17 @@ Performance Improvements
4747
Bug Fixes
4848
~~~~~~~~~
4949

50+
51+
52+
53+
5054
- Bug in ``transform`` causing length mismatch when null entries were present and a fast aggregator was being used (:issue:`9697`)
55+
56+
57+
58+
59+
60+
61+
62+
63+
- Bug in ``Series.quantile`` on empty Series of type ``Datetime`` or ``Timedelta`` (:issue:`9675`)

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ def _maybe_box(self, func, dropna=False):
20952095
boxer = com.i8_boxer(self)
20962096

20972097
if len(values) == 0:
2098-
return boxer(iNaT)
2098+
return boxer(tslib.iNaT)
20992099

21002100
values = values.view('i8')
21012101
result = func(values)

pandas/tests/test_series.py

+5
Original file line numberDiff line numberDiff line change
@@ -6837,6 +6837,11 @@ def test_repeat(self):
68376837
def test_unique_data_ownership(self):
68386838
# it works! #1807
68396839
Series(Series(["a", "c", "b"]).unique()).sort()
6840+
6841+
def test_datetime_timedelta_quantiles(self):
6842+
# covers #9694
6843+
self.assertTrue(pd.isnull(Series([],dtype='M8[ns]').quantile(.5)))
6844+
self.assertTrue(pd.isnull(Series([],dtype='m8[ns]').quantile(.5)))
68406845

68416846
if __name__ == '__main__':
68426847
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],

0 commit comments

Comments
 (0)