Skip to content

Commit be0b0cd

Browse files
committed
PERF: add asv benchmarks for cut()/qcut()
1 parent d90cf7c commit be0b0cd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

asv_bench/benchmarks/reshape.py

+22
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,26 @@ def time_get_dummies_1d_sparse(self):
146146
pd.get_dummies(self.s, sparse=True)
147147

148148

149+
class Cut(object):
150+
params = [[4, 10, 1000]]
151+
param_names = ['bins']
152+
153+
def setup(self, bins):
154+
N = 10**5
155+
self.int_series = pd.Series(np.arange(N).repeat(5))
156+
self.float_series = pd.Series(np.random.randn(N).repeat(5))
157+
158+
def time_cut_int(self, bins):
159+
pd.cut(self.int_series, bins)
160+
161+
def time_cut_float(self, bins):
162+
pd.cut(self.float_series, bins)
163+
164+
def time_qcut_int(self, bins):
165+
pd.qcut(self.int_series, bins)
166+
167+
def time_qcut_float(self, bins):
168+
pd.qcut(self.float_series, bins)
169+
170+
149171
from .pandas_vb_common import setup # noqa: F401

0 commit comments

Comments
 (0)