|
1 | 1 | from .pandas_vb_common import *
|
2 | 2 |
|
3 | 3 |
|
4 |
| -class stat_ops_frame_mean_float_axis_0(object): |
5 |
| - goal_time = 0.2 |
6 |
| - |
7 |
| - def setup(self): |
8 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
9 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
10 |
| - |
11 |
| - def time_stat_ops_frame_mean_float_axis_0(self): |
12 |
| - self.df.mean() |
13 |
| - |
14 |
| - |
15 |
| -class stat_ops_frame_mean_float_axis_1(object): |
16 |
| - goal_time = 0.2 |
17 |
| - |
18 |
| - def setup(self): |
19 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
20 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
21 |
| - |
22 |
| - def time_stat_ops_frame_mean_float_axis_1(self): |
23 |
| - self.df.mean(1) |
24 |
| - |
25 |
| - |
26 |
| -class stat_ops_frame_mean_int_axis_0(object): |
27 |
| - goal_time = 0.2 |
28 |
| - |
29 |
| - def setup(self): |
30 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
31 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
32 |
| - |
33 |
| - def time_stat_ops_frame_mean_int_axis_0(self): |
34 |
| - self.dfi.mean() |
35 |
| - |
36 |
| - |
37 |
| -class stat_ops_frame_mean_int_axis_1(object): |
38 |
| - goal_time = 0.2 |
| 4 | +def _set_use_bottleneck_False(): |
| 5 | + try: |
| 6 | + pd.options.compute.use_bottleneck = False |
| 7 | + except: |
| 8 | + from pandas.core import nanops |
| 9 | + nanops._USE_BOTTLENECK = False |
39 | 10 |
|
40 |
| - def setup(self): |
41 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
42 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
43 |
| - |
44 |
| - def time_stat_ops_frame_mean_int_axis_1(self): |
45 |
| - self.dfi.mean(1) |
46 |
| - |
47 |
| - |
48 |
| -class stat_ops_frame_sum_float_axis_0(object): |
49 |
| - goal_time = 0.2 |
50 | 11 |
|
51 |
| - def setup(self): |
52 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
53 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
54 |
| - |
55 |
| - def time_stat_ops_frame_sum_float_axis_0(self): |
56 |
| - self.df.sum() |
57 |
| - |
58 |
| - |
59 |
| -class stat_ops_frame_sum_float_axis_1(object): |
| 12 | +class FrameOps(object): |
60 | 13 | goal_time = 0.2
|
61 | 14 |
|
62 |
| - def setup(self): |
63 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
64 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
| 15 | + param_names = ['op', 'use_bottleneck', 'dtype', 'axis'] |
| 16 | + params = [['mean', 'sum', 'median'], |
| 17 | + [True, False], |
| 18 | + ['float', 'int'], |
| 19 | + [0, 1]] |
65 | 20 |
|
66 |
| - def time_stat_ops_frame_sum_float_axis_1(self): |
67 |
| - self.df.sum(1) |
| 21 | + def setup(self, op, use_bottleneck, dtype, axis): |
| 22 | + if dtype == 'float': |
| 23 | + self.df = DataFrame(np.random.randn(100000, 4)) |
| 24 | + elif dtype == 'int': |
| 25 | + self.df = DataFrame(np.random.randint(1000, size=(100000, 4))) |
68 | 26 |
|
| 27 | + if not use_bottleneck: |
| 28 | + _set_use_bottleneck_False() |
69 | 29 |
|
70 |
| -class stat_ops_frame_sum_int_axis_0(object): |
71 |
| - goal_time = 0.2 |
72 |
| - |
73 |
| - def setup(self): |
74 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
75 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
76 |
| - |
77 |
| - def time_stat_ops_frame_sum_int_axis_0(self): |
78 |
| - self.dfi.sum() |
79 |
| - |
80 |
| - |
81 |
| -class stat_ops_frame_sum_int_axis_1(object): |
82 |
| - goal_time = 0.2 |
83 |
| - |
84 |
| - def setup(self): |
85 |
| - self.df = DataFrame(np.random.randn(100000, 4)) |
86 |
| - self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape)) |
| 30 | + self.func = getattr(self.df, op) |
87 | 31 |
|
88 |
| - def time_stat_ops_frame_sum_int_axis_1(self): |
89 |
| - self.dfi.sum(1) |
| 32 | + def time_op(self, op, use_bottleneck, dtype, axis): |
| 33 | + self.func(axis=axis) |
90 | 34 |
|
91 | 35 |
|
92 | 36 | class stat_ops_level_frame_sum(object):
|
|
0 commit comments