Dask Dataframe错误:“ Future”对象没有属性“ drop”

时间:2019-05-02 08:21:54

标签: python dask

我对Dask陌生。我创建了一个dask数据框,使用drop命令删除了一些列。之后,我将执行其他操作。当我调用compute时,出现错误:“ Future”对象没有属性“ drop”。

在drop命令之后立即调用compute()可以正常工作,但是当我在之后调用几条语句时,会出现此错误。请在这里指出问题所在。

顺便说一句,我正在使用分布在本地计算机上的dask,版本是1.2.1。

import dask.dataframe as dd  
from dask.distributed import Client  
client = Client()   
df = dd.read_csv("XYZ.csv", sep="\t",low_memory=False) #Its about 3 GB in size   
df = df.persist() #Data is split ito 47 partitions   

list_of_columns_to_delete = ['ABC', 'AXY', 'JDR']    

df = df.drop(list_of_columns_to_delete, axis=1, errors=True)   

df.EngineSpeed.mean().compute() #this works fine and computes the mean   
df = df[(df.Time < "23:59:59") ]   
df = df[df.EngineSpeed > 605]   
df = df[df.ServiceBrakeCircuit1AirPressure.notnull()]   
df = df[df.ServiceBrakeCircuit2AirPressure.notnull()]   
df.GpsSpeed = df.GpsSpeed.where(df.GpsSpeed < 111,111)    
df.GpsSpeed.mean().compute() #This gives 'Future' object has no attribute 'drop' error`     

请提出错误的含义以及如何纠正该错误。

1 个答案:

答案 0 :(得分:1)

我尝试使用相似的数据集产生错误,并且一切正常

In [1]: import dask

In [2]: df = dask.datasets.timeseries()

In [3]: from dask.distributed import Client

In [4]: client = Client()

In [5]: df = df.persist()

In [6]: df
Out[6]:
Dask DataFrame Structure:
                   id    name        x        y
npartitions=30
2000-01-01      int64  object  float64  float64
2000-01-02        ...     ...      ...      ...
...               ...     ...      ...      ...
2000-01-30        ...     ...      ...      ...
2000-01-31        ...     ...      ...      ...
Dask Name: make-timeseries, 30 tasks

In [7]: df = df.drop(['x', 'name'], axis=1, errors=True)

In [8]: df.y.mean().compute()
Out[8]: 0.00012229375505932677

我建议制作一个MCVE