dask.bag.Bag.topk

dask.bag.Bag.topk

Bag.topk(k, key=None, split_every=None)[source]

K largest elements in collection

Optionally ordered by some key function

>>> import dask.bag as db
>>> b = db.from_sequence([10, 3, 5, 7, 11, 4])
>>> list(b.topk(2))
[11, 10]
>>> list(b.topk(2, lambda x: -x))
[3, 4]