Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
上下文:Dask 文档明确指出,Bag.take()只会从第一个分区收集。但是,当使用过滤器时,可能会出现第一个分区是空的,而其他分区不是。
Bag.take()
问题:是否可以使用Bag.take()它从足够数量的分区收集n项目(或最大可用小于n)。
n
您可以执行以下操作:
from toolz import take f = lambda seq: list(take(n, seq)) b.reduction(f, f)
这会获取每个分区的前 n 个元素,将它们全部收集在一起,然后获取结果的前 n 个元素。