简体   繁体   English

将熊猫系列添加到 dask 数据框

[英]Add pandas series to dask dataframe

What is the idiomatic way to add a pandas series to a dask dataframe?将熊猫系列添加到 dask 数据框的惯用方法是什么?

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. Pandas 在处理数据方面要灵活得多,因此我经常将部分 dask 数据帧放入内存,操作列并创建新列。 I would then like to add these new columns to the original dask dataframe.然后,我想将这些新列添加到原始 dask 数据框中。 How can these be accomplished?这些如何实现?

In recent versions of dask.dataframe, you can simply add the pandas.Series directly!在最新版本的 dask.dataframe 中,您可以直接添加 pandas.Series!

# 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. Dask 会自动对 pandas 系列进行分区以匹配 dask.dataframe 的索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM