Skip to content

Commit ac8c79d

Browse files
committed
add asv bench for groupby rank with many ties
1 parent cb3f778 commit ac8c79d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

asv_bench/benchmarks/groupby.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77
from pandas import (DataFrame, Series, MultiIndex, date_range, period_range,
8-
TimeGrouper, Categorical)
8+
TimeGrouper, Categorical, Timestamp)
99
import pandas.util.testing as tm
1010

1111
from .pandas_vb_common import setup # noqa
@@ -385,6 +385,26 @@ def time_dtype_as_field(self, dtype, method, application):
385385
self.as_field_method()
386386

387387

388+
class RankWithTies(object):
389+
# GH 21237
390+
goal_time = 0.2
391+
param_names = ['dtype', 'tie_method']
392+
params = [['float64', 'float32', 'int64', 'datetime64'],
393+
['first', 'average', 'dense', 'min', 'max']]
394+
395+
def setup(self, dtype, tie_method):
396+
N = 10**4
397+
if dtype == 'datetime64':
398+
data = np.array([Timestamp("2011/01/01")] * N, dtype=dtype)
399+
else:
400+
data = np.array([1] * N, dtype=dtype)
401+
self.df = DataFrame({'values': data, 'key': ['foo'] * N})
402+
self.method = tie_method
403+
404+
def time_rank_ties(self, dtype, tie_method):
405+
self.df.groupby('key').rank(method=self.method)
406+
407+
388408
class Float32(object):
389409
# GH 13335
390410
goal_time = 0.2

0 commit comments

Comments
 (0)