【发布时间】:2018-03-09 03:03:41
【问题描述】:
我有一个由镶木地板支持的 dask 数据框。这是 1.31 亿行,当我对整个框架进行一些基本操作时,它们需要几分钟时间。
df = dd.read_parquet('data_*.pqt')
unique_locations = df.location.unique()
https = unique_locations.str.startswith('https:')
http = unique_locations.str.startswith('http:')
total_locations = len(unique_locations)
n_https = https.sum().compute()
n_http = http.sum().compute()
时间:
CPU times: user 2min 49s, sys: 23.9 s, total: 3min 13s
Wall time: 1min 53s
我天真地认为,如果我抽取一个数据样本,我这次可以降低,然后做了:
df = dd.read_parquet('data_*.pqt')
df = df.sample(frac=0.05)
unique_locations = df.location.unique()
https = unique_locations.str.startswith('https:')
http = unique_locations.str.startswith('http:')
total_locations = len(unique_locations)
n_https = https.sum().compute()
n_http = http.sum().compute()
时间:
Unknown, I stopped it after 45minutes.
我猜我的示例无法有效地访问我的所有后续计算,但我不知道如何解决它。
我对从 dask 数据帧中采样数据然后使用该示例的最佳方法感兴趣。
【问题讨论】:
-
如果我做
df = df.get_partition(0),那么计算运行得很快,但这不是我数据的随机样本。我的数据框的分区数与磁盘上的文件数相同,所以我可以用 pandas 读取一个文件,但这不是我想做的采样。 -
没有线索。我建议阅读Understanding Performance 文档,特别是尝试使用 dask.distributed 诊断仪表板来了解什么占用了时间。我建议查看剖面图youtube link
-
另外,您可能需要考虑将三个计算调用与@987654329@ 合二为一
-
我已阅读了解性能。我有一些不错的任务图,但我不了解快速与快速任务图的外观。我的慢速计算有很多并行组件,它们最后都聚集在一起。我认为这会很快。
-
我在本地机器上使用 dask,而不是分布式。我使用了分析器(ResourceProfiler、CacheProfiler 等)并在任务完成后将它们可视化,如此处所述:dask.pydata.org/en/latest/diagnostics-local.html。但是我看不到在操作进行时可视化的方法,所以我不明白如何利用这些工具来处理我运行缓慢的过程。 (最后一次我等了一个多小时 frac=0.01)
标签: dask