|
5 | 5 |
|
6 | 6 | import numpy as np
|
7 | 7 | from pandas import (DataFrame, Series, MultiIndex, date_range, period_range,
|
8 |
| - TimeGrouper, Categorical) |
| 8 | + TimeGrouper, Categorical, Timestamp) |
9 | 9 | import pandas.util.testing as tm
|
10 | 10 |
|
11 | 11 | from .pandas_vb_common import setup # noqa
|
@@ -385,6 +385,26 @@ def time_dtype_as_field(self, dtype, method, application):
|
385 | 385 | self.as_field_method()
|
386 | 386 |
|
387 | 387 |
|
| 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 | + |
388 | 408 | class Float32(object):
|
389 | 409 | # GH 13335
|
390 | 410 | goal_time = 0.2
|
|
0 commit comments