|
1 |
| -from .pandas_vb_common import * |
2 | 1 | import pandas as pd
|
3 | 2 | import numpy as np
|
4 | 3 |
|
| 4 | +from .pandas_vb_common import setup # noqa |
5 | 5 |
|
6 |
| -class DataframeRolling(object): |
7 |
| - goal_time = 0.2 |
8 | 6 |
|
9 |
| - def setup(self): |
10 |
| - self.N = 100000 |
11 |
| - self.Ns = 10000 |
12 |
| - self.df = pd.DataFrame({'a': np.random.random(self.N)}) |
13 |
| - self.dfs = pd.DataFrame({'a': np.random.random(self.Ns)}) |
14 |
| - self.wins = 10 |
15 |
| - self.winl = 1000 |
| 7 | +class Methods(object): |
16 | 8 |
|
17 |
| - def time_rolling_quantile_0(self): |
18 |
| - (self.df.rolling(self.wins).quantile(0.0)) |
| 9 | + sample_time = 0.2 |
| 10 | + params = (['DataFrame', 'Series'], |
| 11 | + [10, 1000], |
| 12 | + ['int', 'float'], |
| 13 | + ['median', 'mean', 'max', 'min', 'std', 'count', 'skew', 'kurt', |
| 14 | + 'sum', 'corr', 'cov']) |
| 15 | + param_names = ['contructor', 'window', 'dtype', 'method'] |
19 | 16 |
|
20 |
| - def time_rolling_quantile_1(self): |
21 |
| - (self.df.rolling(self.wins).quantile(1.0)) |
| 17 | + def setup(self, contructor, window, dtype, method): |
| 18 | + N = 10**5 |
| 19 | + arr = np.random.random(N).astype(dtype) |
| 20 | + self.roll = getattr(pd, contructor)(arr).rolling(window) |
22 | 21 |
|
23 |
| - def time_rolling_quantile_median(self): |
24 |
| - (self.df.rolling(self.wins).quantile(0.5)) |
| 22 | + def time_rolling(self, contructor, window, dtype, method): |
| 23 | + getattr(self.roll, method)() |
25 | 24 |
|
26 |
| - def time_rolling_median(self): |
27 |
| - (self.df.rolling(self.wins).median()) |
28 | 25 |
|
29 |
| - def time_rolling_mean(self): |
30 |
| - (self.df.rolling(self.wins).mean()) |
| 26 | +class Quantile(object): |
31 | 27 |
|
32 |
| - def time_rolling_max(self): |
33 |
| - (self.df.rolling(self.wins).max()) |
| 28 | + sample_time = 0.2 |
| 29 | + params = (['DataFrame', 'Series'], |
| 30 | + [10, 1000], |
| 31 | + ['int', 'float'], |
| 32 | + [0, 0.5, 1]) |
| 33 | + param_names = ['contructor', 'window', 'dtype', 'percentile'] |
34 | 34 |
|
35 |
| - def time_rolling_min(self): |
36 |
| - (self.df.rolling(self.wins).min()) |
| 35 | + def setup(self, contructor, window, dtype, percentile): |
| 36 | + N = 10**5 |
| 37 | + arr = np.random.random(N).astype(dtype) |
| 38 | + self.roll = getattr(pd, contructor)(arr).rolling(window) |
37 | 39 |
|
38 |
| - def time_rolling_std(self): |
39 |
| - (self.df.rolling(self.wins).std()) |
40 |
| - |
41 |
| - def time_rolling_count(self): |
42 |
| - (self.df.rolling(self.wins).count()) |
43 |
| - |
44 |
| - def time_rolling_skew(self): |
45 |
| - (self.df.rolling(self.wins).skew()) |
46 |
| - |
47 |
| - def time_rolling_kurt(self): |
48 |
| - (self.df.rolling(self.wins).kurt()) |
49 |
| - |
50 |
| - def time_rolling_sum(self): |
51 |
| - (self.df.rolling(self.wins).sum()) |
52 |
| - |
53 |
| - def time_rolling_corr(self): |
54 |
| - (self.dfs.rolling(self.wins).corr()) |
55 |
| - |
56 |
| - def time_rolling_cov(self): |
57 |
| - (self.dfs.rolling(self.wins).cov()) |
58 |
| - |
59 |
| - def time_rolling_quantile_0_l(self): |
60 |
| - (self.df.rolling(self.winl).quantile(0.0)) |
61 |
| - |
62 |
| - def time_rolling_quantile_1_l(self): |
63 |
| - (self.df.rolling(self.winl).quantile(1.0)) |
64 |
| - |
65 |
| - def time_rolling_quantile_median_l(self): |
66 |
| - (self.df.rolling(self.winl).quantile(0.5)) |
67 |
| - |
68 |
| - def time_rolling_median_l(self): |
69 |
| - (self.df.rolling(self.winl).median()) |
70 |
| - |
71 |
| - def time_rolling_mean_l(self): |
72 |
| - (self.df.rolling(self.winl).mean()) |
73 |
| - |
74 |
| - def time_rolling_max_l(self): |
75 |
| - (self.df.rolling(self.winl).max()) |
76 |
| - |
77 |
| - def time_rolling_min_l(self): |
78 |
| - (self.df.rolling(self.winl).min()) |
79 |
| - |
80 |
| - def time_rolling_std_l(self): |
81 |
| - (self.df.rolling(self.wins).std()) |
82 |
| - |
83 |
| - def time_rolling_count_l(self): |
84 |
| - (self.df.rolling(self.wins).count()) |
85 |
| - |
86 |
| - def time_rolling_skew_l(self): |
87 |
| - (self.df.rolling(self.wins).skew()) |
88 |
| - |
89 |
| - def time_rolling_kurt_l(self): |
90 |
| - (self.df.rolling(self.wins).kurt()) |
91 |
| - |
92 |
| - def time_rolling_sum_l(self): |
93 |
| - (self.df.rolling(self.wins).sum()) |
94 |
| - |
95 |
| - |
96 |
| -class SeriesRolling(object): |
97 |
| - goal_time = 0.2 |
98 |
| - |
99 |
| - def setup(self): |
100 |
| - self.N = 100000 |
101 |
| - self.Ns = 10000 |
102 |
| - self.df = pd.DataFrame({'a': np.random.random(self.N)}) |
103 |
| - self.dfs = pd.DataFrame({'a': np.random.random(self.Ns)}) |
104 |
| - self.sr = self.df.a |
105 |
| - self.srs = self.dfs.a |
106 |
| - self.wins = 10 |
107 |
| - self.winl = 1000 |
108 |
| - |
109 |
| - def time_rolling_quantile_0(self): |
110 |
| - (self.sr.rolling(self.wins).quantile(0.0)) |
111 |
| - |
112 |
| - def time_rolling_quantile_1(self): |
113 |
| - (self.sr.rolling(self.wins).quantile(1.0)) |
114 |
| - |
115 |
| - def time_rolling_quantile_median(self): |
116 |
| - (self.sr.rolling(self.wins).quantile(0.5)) |
117 |
| - |
118 |
| - def time_rolling_median(self): |
119 |
| - (self.sr.rolling(self.wins).median()) |
120 |
| - |
121 |
| - def time_rolling_mean(self): |
122 |
| - (self.sr.rolling(self.wins).mean()) |
123 |
| - |
124 |
| - def time_rolling_max(self): |
125 |
| - (self.sr.rolling(self.wins).max()) |
126 |
| - |
127 |
| - def time_rolling_min(self): |
128 |
| - (self.sr.rolling(self.wins).min()) |
129 |
| - |
130 |
| - def time_rolling_std(self): |
131 |
| - (self.sr.rolling(self.wins).std()) |
132 |
| - |
133 |
| - def time_rolling_count(self): |
134 |
| - (self.sr.rolling(self.wins).count()) |
135 |
| - |
136 |
| - def time_rolling_skew(self): |
137 |
| - (self.sr.rolling(self.wins).skew()) |
138 |
| - |
139 |
| - def time_rolling_kurt(self): |
140 |
| - (self.sr.rolling(self.wins).kurt()) |
141 |
| - |
142 |
| - def time_rolling_sum(self): |
143 |
| - (self.sr.rolling(self.wins).sum()) |
144 |
| - |
145 |
| - def time_rolling_corr(self): |
146 |
| - (self.srs.rolling(self.wins).corr()) |
147 |
| - |
148 |
| - def time_rolling_cov(self): |
149 |
| - (self.srs.rolling(self.wins).cov()) |
150 |
| - |
151 |
| - def time_rolling_quantile_0_l(self): |
152 |
| - (self.sr.rolling(self.winl).quantile(0.0)) |
153 |
| - |
154 |
| - def time_rolling_quantile_1_l(self): |
155 |
| - (self.sr.rolling(self.winl).quantile(1.0)) |
156 |
| - |
157 |
| - def time_rolling_quantile_median_l(self): |
158 |
| - (self.sr.rolling(self.winl).quantile(0.5)) |
159 |
| - |
160 |
| - def time_rolling_median_l(self): |
161 |
| - (self.sr.rolling(self.winl).median()) |
162 |
| - |
163 |
| - def time_rolling_mean_l(self): |
164 |
| - (self.sr.rolling(self.winl).mean()) |
165 |
| - |
166 |
| - def time_rolling_max_l(self): |
167 |
| - (self.sr.rolling(self.winl).max()) |
168 |
| - |
169 |
| - def time_rolling_min_l(self): |
170 |
| - (self.sr.rolling(self.winl).min()) |
171 |
| - |
172 |
| - def time_rolling_std_l(self): |
173 |
| - (self.sr.rolling(self.wins).std()) |
174 |
| - |
175 |
| - def time_rolling_count_l(self): |
176 |
| - (self.sr.rolling(self.wins).count()) |
177 |
| - |
178 |
| - def time_rolling_skew_l(self): |
179 |
| - (self.sr.rolling(self.wins).skew()) |
180 |
| - |
181 |
| - def time_rolling_kurt_l(self): |
182 |
| - (self.sr.rolling(self.wins).kurt()) |
183 |
| - |
184 |
| - def time_rolling_sum_l(self): |
185 |
| - (self.sr.rolling(self.wins).sum()) |
| 40 | + def time_quantile(self, contructor, window, dtype, percentile): |
| 41 | + self.roll.quantile(percentile) |
0 commit comments