- Bag.take(k, npartitions=1, compute=True, warn=True)¶
Take the first k elements.
The number of elements to return
- npartitionsint, optional
Elements are only taken from the first
npartitions, with a default of 1. If there are fewer than
krows in the first
npartitionsa warning will be raised and any found rows returned. Pass -1 to use all partitions.
- computebool, optional
Whether to compute the result, default is True.
- warnbool, optional
Whether to warn if the number of elements returned is less than requested, default is True.
- >>> import dask.bag as db
- >>> b = db.from_sequence(range(1_000))
- >>> b.take(3)
- (0, 1, 2)