【发布时间】:2022-01-24 05:46:05
【问题描述】:
我正在使用Dask 应用一个函数myfunc,它将两个新列new_col_1 和new_col_2 添加到我的Dask 数据框data。该函数使用a1 和a2 两列来计算新列。
ddata[['new_col_1', 'new_col_2']] = ddata.map_partitions(
lambda df: df.apply((lambda row: myfunc(row['a1'], row['a2'])), axis=1,
result_type="expand")).compute()
这会产生以下错误:
ValueError: Metadata inference failed in `lambda`.
You have supplied a custom function and Dask is unable to determine the type of output that that function returns.
To resolve this please provide a meta= keyword.
如何为这种情况提供meta 关键字?
【问题讨论】:
标签: python pandas apply dask dask-distributed