# dask.bag.Bag.take

Bag.take(k, npartitions=1, compute=True, warn=True)

  Take the first k elements.

  Parameters:
    k int

      The number of elements to return

    npartitions int, optional

      Elements are only taken from the first `npartitions`, with a default of 1. If there are fewer than `k` rows in the first `npartitions` a warning will be raised and any found rows returned. Pass -1 to use all partitions.

    compute bool, optional

      Whether to compute the result, default is True.

    warn bool, 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)