@@ -358,24 +358,24 @@ def _fail_neg(values, errmsg='negative value'):
358
358
def _rank (data , / , * , key = None , reverse = False , ties = 'average' ) -> list [float ]:
359
359
"""Rank order a dataset. The lowest value has rank 1.
360
360
361
- Ties are averaged so that equal values receive the same rank.
361
+ Ties are averaged so that equal values receive the same rank:
362
362
363
- >>> data = [31, 56, 31, 25, 75, 18]
364
- >>> _rank(data)
365
- [3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
363
+ >>> data = [31, 56, 31, 25, 75, 18]
364
+ >>> _rank(data)
365
+ [3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
366
366
367
- The operation is idempotent.
367
+ The operation is idempotent:
368
368
369
- >>> _rank([3.5, 5.0, 3.5, 2.0, 6.0, 1.0])
370
- [3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
369
+ >>> _rank([3.5, 5.0, 3.5, 2.0, 6.0, 1.0])
370
+ [3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
371
371
372
372
It is possible to rank the data in reverse order so that
373
373
the highest value has rank 1. Also, a key-function can
374
374
extract the field to be ranked:
375
375
376
- >>> goals = [('eagles', 45), ('bears', 48), ('lions', 44)]
377
- >>> _rank(goals, key=itemgetter(1), reverse=True)
378
- [2.0, 1.0, 3.0]
376
+ >>> goals = [('eagles', 45), ('bears', 48), ('lions', 44)]
377
+ >>> _rank(goals, key=itemgetter(1), reverse=True)
378
+ [2.0, 1.0, 3.0]
379
379
380
380
"""
381
381
# If this function becomes public at some point, more thought
0 commit comments