Skip to content

Commit 2b10024

Browse files
committed
Update ASVs, docs and tests
1 parent 822a736 commit 2b10024

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
@@ -1257,15 +1257,14 @@ def kurt(self, **kwargs):
12571257
fractional part of the index surrounded by `i` and `j`.
12581258
* lower: `i`.
12591259
* higher: `j`.
1260-
* nearest: `i` or `j` whichever is nearest. Implementation uses
1261-
round() built-in.
1260+
* nearest: `i` or `j` whichever is nearest.
12621261
* midpoint: (`i` + `j`) / 2.
12631262
12641263
Returns
12651264
-------
12661265
Series or DataFrame
12671266
Returned object type is determined by the caller of the %(name)s
1268-
calculation
1267+
calculation.
12691268
12701269
Examples
12711270
--------
@@ -1286,8 +1285,10 @@ def kurt(self, **kwargs):
12861285
12871286
See Also
12881287
--------
1289-
pandas.Series.quantile
1290-
pandas.DataFrame.quantile
1288+
pandas.Series.quantile : Computes value at the given quantile over all data
1289+
in Series.
1290+
pandas.DataFrame.quantile : Computes values at the given quantile over
1291+
requested axis in DataFrame.
12911292
12921293
""")
12931294

pandas/tests/test_window.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,14 +1140,14 @@ def test_rolling_quantile_np_percentile(self):
11401140
[np.nan, np.nan, np.nan, np.nan],
11411141
[np.nan, 0.1, np.nan, 0.3, 0.4, 0.5],
11421142
[0.5], [np.nan, 0.7, 0.6]])
1143-
def test_rolling_quantile_interpolation_options(self, quantile,
1144-
interpolation, data):
1143+
def test_moving_quantile_interpolation_options(self, quantile,
1144+
interpolation, data):
11451145
# Tests that rolling window's quantile behavior is analogous to
11461146
# Series' quantile for each interpolation option
11471147
s = Series(data)
11481148

11491149
q1 = s.quantile(quantile, interpolation)
1150-
q2 = s.rolling(len(data), min_periods=1).quantile(
1150+
q2 = s.expanding(min_periods=1).quantile(
11511151
quantile, interpolation).iloc[-1]
11521152

11531153
if np.isnan(q1):
@@ -1164,7 +1164,7 @@ def test_invalid_quantile_value(self):
11641164
s.rolling(len(data), min_periods=1).quantile(
11651165
0.5, interpolation='invalid')
11661166

1167-
def test_rolling_quantile_param(self):
1167+
def test_moving_quantile_param(self):
11681168
ser = Series([0.0, .1, .5, .9, 1.0])
11691169

11701170
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)