【问题标题】:Losing performance when coverting Dask do Pandas - compute()将 Dask 转换为 Pandas 时性能下降 - compute()
【发布时间】:2021-05-23 16:28:40
【问题描述】:

我正在使用 Dask 在 python 中读取一个大文本文件以提高内存性能。

我正在使用 df.compute()Dask 数据帧转换为 Pandas 以执行 Pandas 的大量转换。我看到df.compute() 之后的内存使用量(guppy3)增加了5x

df = dd.read_csv('some_big_file - Copy.csv', sep = '|', names = names)

j = hpy()
print(j.heap())     
##checked only 45mb memory

df = df.compute() 

j = hpy()
print(j.heap())
##Checked almost 230mb memory usage

我错过了什么?

【问题讨论】:

    标签: python pandas dask


    【解决方案1】:

    运行df = df.compute()会将数据帧带入内存,而之前的数据帧是lazy,所以Python/dask只知道如何访问数据帧,并没有将其加载到内存中。

    【讨论】:

    猜你喜欢
    • 2021-02-05
    • 2020-07-28
    • 1970-01-01
    • 2014-08-23
    • 1970-01-01
    • 2017-02-04
    • 2013-03-13
    • 2019-06-25
    • 2017-02-18
    相关资源
    最近更新 更多