替换简单的数据框分区 [英] Replace a dask dataframe partition

查看:86
本文介绍了替换简单的数据框分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以用我单独创建的,具有相同行数和相同结构的另一个dask数据帧分区替换一个dask数据帧分区吗?
如果可以,怎么办?

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?

行数是否可能不同?

推荐答案

您可以使用 dd.concat 函数将分区添加到Dask数据帧的开头或结尾。

You can add partitions to the beginning or end of a Dask dataframe using the dd.concat function.

您可以在数据框中的任何位置插入新分区,方法是切换到延迟的对象,将延迟的对象插入列表,然后再切换回dask数据框。

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)

它可以有不同数量的行,但必须具有相同的列和dtypes

It can have a different number of rows, but it must have the same columns and dtypes

这篇关于替换简单的数据框分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆