Skip to content

Commit c8096ef

Browse files
committed
BUG: Series.quantile raising on an object dtype (GH6555)
1 parent 170377d commit c8096ef

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Bug Fixes
219219
wrong data types and missing values (:issue:`6335`)
220220
- Inconsistent types in Timestamp addition/subtraction (:issue:`6543`)
221221
- Bug in indexing: empty list lookup caused ``IndexError`` exceptions (:issue:`6536`, :issue:`6551`)
222-
222+
- Series.quantile raising on an ``object`` dtype (:issue:`6555`)
223223

224224
pandas 0.13.1
225225
-------------

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def quantile(self, q=0.5):
12871287
if len(valid_values) == 0:
12881288
return pa.NA
12891289
result = _quantile(valid_values, q * 100)
1290-
if result.dtype == _TD_DTYPE:
1290+
if not np.isscalar and com.is_timedelta64_dtype(result):
12911291
from pandas.tseries.timedeltas import to_timedelta
12921292
return to_timedelta(result)
12931293

pandas/tests/test_series.py

+4
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,10 @@ def test_quantile(self):
21022102
q = self.ts.quantile(0.9)
21032103
self.assertEqual(q, scoreatpercentile(self.ts.valid(), 90))
21042104

2105+
# object dtype
2106+
q = Series(self.ts,dtype=object).quantile(0.9)
2107+
self.assertEqual(q, scoreatpercentile(self.ts.valid(), 90))
2108+
21052109
def test_describe(self):
21062110
_ = self.series.describe()
21072111
_ = self.ts.describe()

0 commit comments

Comments
 (0)