Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop column using Dask dataframe

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?

like image 351
cs0815 Avatar asked Aug 09 '18 14:08

cs0815


1 Answers

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)
like image 174
jpp Avatar answered Oct 15 '22 16:10

jpp