Dask—获取Dask数据帧中每个分区的行长度的最快方法

Dask—获取Dask数据帧中每个分区的行长度的最快方法,dask,dask-distributed,dask-delayed,fastparquet,Dask,Dask Distributed,Dask Delayed,Fastparquet,我想得到许多数据帧中每个分区的长度。我现在得到每个分区,然后得到每个分区的索引大小。这是非常非常缓慢的。有更好的办法吗 下面是我的代码的简化片段: temp_dd = dd.read_parquet(read_str, gather_statistics=False) temp_dd = dask_client.scatter(temp_dd, broadcast=True) dask_wait([temp_dd]) temp_dd = dask_client.gathe

我想得到许多数据帧中每个分区的长度。我现在得到每个分区,然后得到每个分区的索引大小。这是非常非常缓慢的。有更好的办法吗

下面是我的代码的简化片段:

   temp_dd = dd.read_parquet(read_str, gather_statistics=False)
   temp_dd = dask_client.scatter(temp_dd, broadcast=True)
   dask_wait([temp_dd])
   temp_dd = dask_client.gather(temp_dd)

   while row_batch <= max_row:
       row_batch_dd = temp_dd.get_partition(row_batch)
       row_batch_dd = row_batch_dd.dropna()    
       row_batch_dd_len = row_batch_dd.index.size  # <-- this is the current way I'm determining the length
       row_batch = row_batch + 1
temp\u dd=dd.read\u拼花地板(read\u str,gather\u statistics=False)
temp\u dd=dask\u client.scatter(temp\u dd,broadcast=True)
dask_wait([temp_dd])
temp\u dd=dask\u客户端聚集(temp\u dd)

而第二行的批次说明请?1。将拼花地板文件读入变量
df
。2.从数据帧中删除缺失的值,
df
。3.对于每个
df
分区,计算
len
(这就是
map\u分区的作用)。然后将计算出的值返回给用户(这就是
compute
正在做的事情)。在调用
compute
之前,所有事情都是“懒惰”的,所以您无法完成任何工作。这是因为在正常情况下,
len(df)
将给出数据帧中的行数。当您使用
map\u分区时
一个数据帧被传递到函数中。
df = dd.read_parquet(fn, gather_statistics=False)
df = df.dropna()
df.map_partitions(len).compute()