Skip to content

Commit c0e8601

Browse files
committed
Added quantile method to Resampler
1 parent cc3ab4a commit c0e8601

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ Groupby/Resample/Rolling
650650
``SeriesGroupBy`` when the grouping variable only contains NaNs and numpy version < 1.13 (:issue:`21956`).
651651
- Multiple bugs in :func:`pandas.core.Rolling.min` with ``closed='left'` and a
652652
datetime-like index leading to incorrect results and also segfault. (:issue:`21704`)
653+
- Added :meth:`Resampler.quantile` (:issue:`15023`).
653654
-
654655

655656
Sparse

pandas/core/resample.py

+10
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,16 @@ def size(self):
749749
result = pd.Series([], index=result.index, dtype='int64')
750750
return result
751751

752+
def quantile(self, q=0.5, **kwargs):
753+
"""
754+
Return value at the given quantile.
755+
756+
Parameters
757+
----------
758+
q : float or array-like, default 0.5 (50% quantile)
759+
"""
760+
return self._downsample('quantile', q=q, **kwargs)
761+
752762

753763
# downsample methods
754764
for method in ['sum', 'prod']:

pandas/tests/test_resample.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# The various methods we support
4343
downsample_methods = ['min', 'max', 'first', 'last', 'sum', 'mean', 'sem',
44-
'median', 'prod', 'var', 'ohlc']
44+
'median', 'prod', 'var', 'ohlc', 'quantile']
4545
upsample_methods = ['count', 'size']
4646
series_methods = ['nunique']
4747
resample_methods = downsample_methods + upsample_methods + series_methods

0 commit comments

Comments
 (0)