Drop column using Dask dataframe

僤鯓⒐⒋嵵緔 提交于 2019-12-23 20:13:36

问题


This should work:

raw_data.drop('some_great_column', axis=1).compute()

But the column is not dropped. In pandas I use:

raw_data.drop(['some_great_column'], axis=1, inplace=True)

But inplace does not exist in Dask. Any ideas?


回答1:


You can separate into two operations:

# dask operation
raw_data = raw_data.drop('some_great_column', axis=1)

# conversion to pandas
df = raw_data.compute()

Then export the Pandas dataframe to a CSV file:

df.to_csv(r'out.csv', index=False)


来源:https://stackoverflow.com/questions/51769644/drop-column-using-dask-dataframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!