Skip to content

Commit f9b1e7e

Browse files
committed
Update ASVs, docs and tests
1 parent f21d21a commit f9b1e7e

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

asv_bench/benchmarks/rolling.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def setup(self, constructor, window, dtype, method):
2222
def time_rolling(self, constructor, window, dtype, method):
2323
getattr(self.roll, method)()
2424

25+
2526
class VariableWindowMethods(Methods):
2627
sample_time = 0.2
2728
params = (['DataFrame', 'Series'],
@@ -37,6 +38,7 @@ def setup(self, constructor, window, dtype, method):
3738
index = pd.date_range('2017-01-01', periods=N, freq='5s')
3839
self.roll = getattr(pd, constructor)(arr, index=index).rolling(window)
3940

41+
4042
class Pairwise(object):
4143

4244
sample_time = 0.2
@@ -59,7 +61,6 @@ def time_pairwise(self, window, method, pairwise):
5961

6062

6163
class Quantile(object):
62-
6364
sample_time = 0.2
6465
params = (['DataFrame', 'Series'],
6566
[10, 1000],
@@ -68,9 +69,21 @@ class Quantile(object):
6869
param_names = ['constructor', 'window', 'dtype', 'percentile']
6970

7071
def setup(self, constructor, window, dtype, percentile):
71-
N = 10**5
72+
N = 10 ** 5
7273
arr = np.random.random(N).astype(dtype)
7374
self.roll = getattr(pd, constructor)(arr).rolling(window)
7475

7576
def time_quantile(self, constructor, window, dtype, percentile):
7677
self.roll.quantile(percentile)
78+
79+
def time_quantile_nearest(self, constructor, window, dtype, percentile):
80+
self.roll.quantile(percentile, interpolation='nearest')
81+
82+
def time_quantile_lower(self, constructor, window, dtype, percentile):
83+
self.roll.quantile(percentile, interpolation='lower')
84+
85+
def time_quantile_higher(self, constructor, window, dtype, percentile):
86+
self.roll.quantile(percentile, interpolation='higher')
87+
88+
def time_quantile_midpoint(self, constructor, window, dtype, percentile):
89+
self.roll.quantile(percentile, interpolation='midpoint')

pandas/core/window.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,15 +1287,14 @@ def kurt(self, **kwargs):
12871287
fractional part of the index surrounded by `i` and `j`.
12881288
* lower: `i`.
12891289
* higher: `j`.
1290-
* nearest: `i` or `j` whichever is nearest. Implementation uses
1291-
round() built-in.
1290+
* nearest: `i` or `j` whichever is nearest.
12921291
* midpoint: (`i` + `j`) / 2.
12931292
12941293
Returns
12951294
-------
12961295
Series or DataFrame
12971296
Returned object type is determined by the caller of the %(name)s
1298-
calculation
1297+
calculation.
12991298
13001299
Examples
13011300
--------
@@ -1316,8 +1315,10 @@ def kurt(self, **kwargs):
13161315
13171316
See Also
13181317
--------
1319-
pandas.Series.quantile
1320-
pandas.DataFrame.quantile
1318+
pandas.Series.quantile : Computes value at the given quantile over all data
1319+
in Series.
1320+
pandas.DataFrame.quantile : Computes values at the given quantile over
1321+
requested axis in DataFrame.
13211322
13221323
""")
13231324

pandas/tests/test_window.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,14 +1178,14 @@ def test_rolling_quantile_np_percentile(self):
11781178
[np.nan, np.nan, np.nan, np.nan],
11791179
[np.nan, 0.1, np.nan, 0.3, 0.4, 0.5],
11801180
[0.5], [np.nan, 0.7, 0.6]])
1181-
def test_rolling_quantile_interpolation_options(self, quantile,
1182-
interpolation, data):
1181+
def test_moving_quantile_interpolation_options(self, quantile,
1182+
interpolation, data):
11831183
# Tests that rolling window's quantile behavior is analogous to
11841184
# Series' quantile for each interpolation option
11851185
s = Series(data)
11861186

11871187
q1 = s.quantile(quantile, interpolation)
1188-
q2 = s.rolling(len(data), min_periods=1).quantile(
1188+
q2 = s.expanding(min_periods=1).quantile(
11891189
quantile, interpolation).iloc[-1]
11901190

11911191
if np.isnan(q1):
@@ -1202,7 +1202,7 @@ def test_invalid_quantile_value(self):
12021202
s.rolling(len(data), min_periods=1).quantile(
12031203
0.5, interpolation='invalid')
12041204

1205-
def test_rolling_quantile_param(self):
1205+
def test_moving_quantile_param(self):
12061206
ser = Series([0.0, .1, .5, .9, 1.0])
12071207

12081208
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)