Skip to content

Commit ad87395

Browse files
committed
PERF: add asv benchmarks for cut()/qcut()
1 parent 02d42fb commit ad87395

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

asv_bench/benchmarks/reshape.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,26 @@ def time_get_dummies_1d(self):
145145
def time_get_dummies_1d_sparse(self):
146146
pd.get_dummies(self.s, sparse=True)
147147

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

149170
from .pandas_vb_common import setup # noqa: F401

0 commit comments

Comments
 (0)