2

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?

Jacob Tomlinson
  • 3,341
  • 2
  • 31
  • 62
Dhruv Kumar
  • 399
  • 2
  • 13

1 Answers1

4

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

MRocklin
  • 55,641
  • 23
  • 163
  • 235