Skip to content

Commit 5486e75

Browse files
committed
BUG: .quantile with empty temporal data
1 parent a682616 commit 5486e75

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pandas/core/arrays/_mixins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,7 @@ def _quantile(
512512
else:
513513
# e.g. test_quantile_empty we are empty integer dtype and res_values
514514
# has floating dtype
515-
# TODO: technically __init__ isn't defined here.
516-
# Should we raise NotImplementedError and handle this on NumpyEA?
517-
return type(self)(res_values) # type: ignore[call-arg]
515+
return type(self)._from_sequence(res_values) # type: ignore[call-arg]
518516

519517
# ------------------------------------------------------------------------
520518
# numpy-like methods

pandas/tests/series/methods/test_quantile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,10 @@ def test_quantile_dtype_size(self, any_int_ea_dtype):
245245
result = ser.quantile([0.1, 0.5])
246246
expected = Series([1, 1], dtype=any_int_ea_dtype, index=[0.1, 0.5])
247247
tm.assert_series_equal(result, expected)
248+
249+
250+
@pytest.mark.parametrize("typ", ["datetime64", "timedelta64"])
251+
def test_quantile_empty_datetimelike(typ, unit):
252+
ser = Series([], dtype=f"{typ}[{unit}]")
253+
result = ser.quantile()
254+
assert result is pd.NaT

0 commit comments

Comments
 (0)