Add pandas series to dask dataframe

Viewed 595

What is the idiomatic way to add a pandas series to a dask dataframe?

Pandas is far more flexible for working with data so I often bring parts of dask dataframes into memory, manipulate columns and create new ones. I would then like to add these new columns to the original dask dataframe. How can these be accomplished?

1 Answers

In recent versions of dask.dataframe, you can simply add the pandas.Series directly!

# for dask_df and pandas_series with the same index...
dask_df['newcol'] = pandas_series

Dask will automatically partition the pandas series to match the index of the dask.dataframe.

Related