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

2024-09-26 18:02:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我是达斯克的新人。我创建了一个dask数据帧,使用drop命令删除了一些列。在此之后,我将执行其他操作。当我调用compute时,get error:“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`     

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


Tags: csvimport命令clientdf错误futureerror
1条回答
网友
1楼 · 发布于 2024-09-26 18:02:45

我试着用一个类似的数据集产生错误,结果一切正常

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

相关问题 更多 >

    热门问题