Skip to content

Commit 3f831f2

Browse files
committed
addressed Jeff's comments
1 parent d6f541d commit 3f831f2

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Other Enhancements
182182
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`)
183183
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`)
184184
- :class:`DatetimeIndex` gained :attr:`DatetimeIndex.timetz` attribute. Returns local time with timezone information. (:issue:`21358`)
185-
- Added :meth:`Resampler.quantile` (:issue:`15023`).
185+
- :ref:`Series.resample` and :ref:`DataFrame.resample` have gained the :meth:`Resampler.quantile` (:issue:`15023`).
186186

187187
.. _whatsnew_0240.api_breaking:
188188

pandas/core/resample.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,12 @@ def quantile(self, q=0.5, **kwargs):
757757
----------
758758
q : float or array-like, default 0.5 (50% quantile)
759759
760+
See Also
761+
--------
762+
Series.quantile
763+
DataFrame.quantile
764+
DataFrameGroupBy.quantile
765+
760766
.. versionadded:: 0.24.0
761767
"""
762768
return self._downsample('quantile', q=q, **kwargs)
@@ -1055,7 +1061,8 @@ def _downsample(self, how, **kwargs):
10551061

10561062
if is_subperiod(ax.freq, self.freq):
10571063
# Downsampling
1058-
return self._groupby_and_aggregate(how, grouper=self.grouper)
1064+
return self._groupby_and_aggregate(how, grouper=self.grouper,
1065+
**kwargs)
10591066
elif is_superperiod(ax.freq, self.freq):
10601067
if how == 'ohlc':
10611068
# GH #13083

pandas/tests/test_resample.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,15 @@ def test_apply_to_empty_series(self):
771771

772772
assert_series_equal(result, expected, check_dtype=False)
773773

774+
def test_resample_quantile(self):
775+
# GH 15023
776+
s = self.create_series()
777+
q = 0.75
778+
freq = 'H'
779+
result = s.resample(freq).quantile(q)
780+
expected = s.resample(freq).agg(lambda x: x.quantile(q))
781+
tm.assert_series_equal(result, expected)
782+
774783

775784
class TestDatetimeIndex(Base):
776785
_index_factory = lambda x: date_range
@@ -2165,13 +2174,6 @@ def test_resample_datetime_values(self):
21652174
res = df['timestamp'].resample('2D').first()
21662175
tm.assert_series_equal(res, exp)
21672176

2168-
def test_resample_quantile(self):
2169-
# GH 15023
2170-
s = pd.Series(range(20), index=date_range('2016-01-01', periods=20))
2171-
result = s.resample('W').quantile(0.75)
2172-
expected = s.resample('W').agg(lambda x: x.quantile(0.75))
2173-
tm.assert_series_equal(result, expected)
2174-
21752177

21762178
class TestPeriodIndex(Base):
21772179
_index_factory = lambda x: period_range

0 commit comments

Comments
 (0)