Skip to content

Commit

Permalink
Merge pull request #6558 from jreback/quantile_object
Browse files Browse the repository at this point in the history
BUG: Series.quantile raising on an object dtype (GH6555)
  • Loading branch information
jreback committed Mar 6, 2014
2 parents 170377d + c8096ef commit 3590d8c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Bug Fixes
wrong data types and missing values (:issue:`6335`)
- Inconsistent types in Timestamp addition/subtraction (:issue:`6543`)
- Bug in indexing: empty list lookup caused ``IndexError`` exceptions (:issue:`6536`, :issue:`6551`)

- Series.quantile raising on an ``object`` dtype (:issue:`6555`)

pandas 0.13.1
-------------
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ def quantile(self, q=0.5):
if len(valid_values) == 0:
return pa.NA
result = _quantile(valid_values, q * 100)
if result.dtype == _TD_DTYPE:
if not np.isscalar and com.is_timedelta64_dtype(result):
from pandas.tseries.timedeltas import to_timedelta
return to_timedelta(result)

Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,10 @@ def test_quantile(self):
q = self.ts.quantile(0.9)
self.assertEqual(q, scoreatpercentile(self.ts.valid(), 90))

# object dtype
q = Series(self.ts,dtype=object).quantile(0.9)
self.assertEqual(q, scoreatpercentile(self.ts.valid(), 90))

def test_describe(self):
_ = self.series.describe()
_ = self.ts.describe()
Expand Down

0 comments on commit 3590d8c

Please sign in to comment.