Replace a dask dataframe partition

天涯浪子 提交于 2019-12-22 00:35:40

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/51100606/replace-a-dask-dataframe-partition

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