Reputation: 419
Can I replace a dask dataframe partition, with another dask dataframe partition that I've created separately, of the same number of rows and same structure? If yes, how?
Is it possible with a different number of rows?
Upvotes: 2
Views: 385
Reputation: 57261
You can add partitions to the beginning or end of a Dask dataframe using the dd.concat
function.
You can insert a new partition anywhere in the dataframe by switching to delayed objects, inserting a delayed object into the list, and then switching back to dask dataframe
list_of_delayed = dask_df.to_delayed()
new_partition = dask.delayed(pd.read_csv)(filename)
list_of_delayed[i] = new_partition
new_dask_df = dd.from_delayed(list_of_delayed, meta=dask_df._meta)
It can have a different number of rows, but it must have the same columns and dtypes
Upvotes: 5