|
51 | 51 | 'move_std': 'std', 'move_min': 'min',
|
52 | 52 | 'move_max': 'max', 'move_var': 'var',
|
53 | 53 | 'move_argmin': 'argmin', 'move_argmax': 'argmax',
|
54 |
| - 'move_median': 'median'} |
| 54 | + 'move_median': 'median'} #, 'move_rank': 'rank'} |
55 | 55 | # TODO: wrap take, dot, sort
|
56 | 56 |
|
57 | 57 |
|
|
121 | 121 | """
|
122 | 122 |
|
123 | 123 |
|
| 124 | +_BN_RANK_DOC = """\ |
| 125 | +Ranks the data, dealing with ties and NaNs appropriately. |
| 126 | +
|
| 127 | +Equal values are assigned a rank that is the average of the ranks that |
| 128 | +would have been otherwise assigned to all of the values within that set. |
| 129 | +Ranks begin at 1, not 0. |
| 130 | +
|
| 131 | +NaNs in the input array are returned as NaNs. |
| 132 | +
|
| 133 | +Parameters |
| 134 | +---------- |
| 135 | +dim : str, optional |
| 136 | + Dimension(s) over which to apply `{name}`. |
| 137 | +axis : int, optional |
| 138 | + Axis over which to apply `{name}`. Either the 'dim' |
| 139 | + or the 'axis' argument must be supplied. |
| 140 | +
|
| 141 | +Returns |
| 142 | +------- |
| 143 | +ranked: {cls} |
| 144 | + New {cls} object with `{name}` applied to its data along the |
| 145 | + indicated dimension. The dtype is 'float64'. |
| 146 | +""" |
| 147 | + |
| 148 | + |
124 | 149 | def fillna(data, other, join="left", dataset_join="left"):
|
125 | 150 | """Fill missing values in this object with data from the other object.
|
126 | 151 | Follows normal broadcasting and alignment rules.
|
@@ -305,6 +330,17 @@ def inject_binary_ops(cls, inplace=False):
|
305 | 330 | cls._inplace_binary_op(get_op('i' + name)))
|
306 | 331 |
|
307 | 332 |
|
| 333 | +def inject_bottleneck_rank(cls): |
| 334 | + name = 'rank' |
| 335 | + f = getattr(duck_array_ops, name) |
| 336 | + include_skipna = False |
| 337 | + numeric_only = getattr(f, 'numeric_only', False) |
| 338 | + func = cls._reduce_method(f, include_skipna, numeric_only) |
| 339 | + func.__name__ = name |
| 340 | + func.__doc__ = _BN_RANK_DOC.format(name=name, cls=cls.__name__) |
| 341 | + setattr(cls, name, func) |
| 342 | + |
| 343 | + |
308 | 344 | def inject_all_ops_and_reduce_methods(cls, priority=50, array_only=True):
|
309 | 345 | # prioritize our operations over those of numpy.ndarray (priority=1)
|
310 | 346 | # and numpy.matrix (priority=10)
|
@@ -334,6 +370,8 @@ def inject_all_ops_and_reduce_methods(cls, priority=50, array_only=True):
|
334 | 370 |
|
335 | 371 | inject_reduce_methods(cls)
|
336 | 372 | inject_cum_methods(cls)
|
| 373 | + if has_bottleneck: |
| 374 | + inject_bottleneck_rank(cls) |
337 | 375 |
|
338 | 376 |
|
339 | 377 | def inject_bottleneck_rolling_methods(cls):
|
|
0 commit comments