Я пытаюсь использовать dask для применения с функцией, которая выводит 5 поплавков. Я приведу пример в упрощенном виде.
def func1(row, param):
return float(row.Val1) * param, float(row.Val1) * np.power(param, 2)
data = pd.DataFrame(np.array([["A01", 12], ["A02", 24], ["A03", 13]]), columns=["ID", "Val1"])
data2 = dd.from_pandas(data, npartitions=2).map_partitions(lambda df: df.apply(lambda row: func1(row, 2), axis=1, result_type="expand"), meta=pd.DataFrame()).compute(scheduler=get)
Если я не поставлю мету, я получаю это сообщение об ошибке:
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.
The docstring of the Dask function you ran should have more information.
Original error is below:
------------------------
ValueError("could not convert string to float: 'foo'", 'occurred at index 0')
И если я добавлю мету (может быть, не совсем подходящую ...), я получу такую:
ValueError: The columns in the computed data do not match the columns in the provided metadata
Кто-нибудь может помочь? :)