【发布时间】:2020-06-26 03:25:48
【问题描述】:
我正在使用dask,我需要先使用compute() 执行转换才能继续工作流程。在第二次转换期间似乎对象的类型发生了变化并且正在引发错误'DataFrame' object has no attribute 'compute'
我当前的代码如下:
newtypes = {"age":int, "is_superuser":bool}
df = df.astype(newtypes).compute()
# ....
#
....
strtypes = {"age":str, "is_superuser":str)
df = df.astype(strtypes).compute() # Here is raised the exception.
【问题讨论】:
-
检查
type(df)可能是熊猫数据框不支持compute -
你是对的,它从
<class 'dask.dataframe.core.DataFrame'>变为<class 'pandas.core.frame.DataFrame'>。知道如何解决它吗?我读到了delayed,但由于我需要立即执行转换,这不是我的选择。 -
这可能会有所帮助,stackoverflow.com/a/39722445/4985099
-
请首先考虑您要达到的目标,然后重新表述您的问题。
标签: python pandas dataframe dask