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:
------------------------
AttributeError("'Series' object has no attribute 'c'", 'occurred at index b')
Traceback:
---------
File "/opt/conda/lib/python3.6/site-packages/dask/dataframe/utils.py", line 137, in raise_on_meta_error
yield
File "/opt/conda/lib/python3.6/site-packages/dask/dataframe/core.py", line 3477, in _emulate
return func(*_extract_meta(args, True), **_extract_meta(kwargs, True))
File "", line 2, in
ddf.map_partitions(lambda df : df.apply(lambda x : elementsearch((x.b,x.c),axis=1)))
File "/opt/conda/lib/python3.6/site-packages/pandas/core/frame.py", line 6014, in apply
return op.get_result()
File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 318, in get_result
return super(FrameRowApply, self).get_result()
File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 142, in get_result
return self.apply_standard()
File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 248, in apply_standard
self.apply_series_generator()
File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 277, in apply_series_generator
results[i] = self.f(v)
File "", line 2, in
ddf.map_partitions(lambda df : df.apply(lambda x : elementsearch((x.b,x.c),axis=1)))
File "/opt/conda/lib/python3.6/site-packages/pandas/core/generic.py", line 4376, in __getattr__
return object.__getattribute__(self, name)
Я отправил этот вопрос в Stack Overflow, но у меня это не сработало:
В Dask DataFrame.apply() получение n строк со значением 1 до обработки фактических строк.
Как я могу решить эту проблему?>
У меня есть фрейм данных: [code]import numpy as np import pandas as pd import dask.dataframe as dd a = {'b':['cat','bat','cat','cat','bat','No Data','bat','No Data'], 'c':['str1','str2','str3', 'str4','str5','str6','str7', 'str8'] } df11 = pd.DataFrame(a,index=['x1','x2','x3','x4','x5','x6','x7','x8']) [/code] Я попытался извлечь каждый элемент построчно и в обычном кадре данных с помощью лямбда-функции, как показано ниже: [code]def elementsearch(term1, term2): print(term1, term2 ) return term1
df11.apply(lambda x: elementsearch(x.b,x.c), axis =1) [/code] Все работает нормально. Но когда я использую библиотеку dask: [code]ddf = dd.from_pandas(df11,npartitions=8) ddf.map_partitions(lambda df : df.apply(lambda x : elementsearch((x.b,x.c),axis=1))) [/code] Выдала ошибку типа: [code]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: ------------------------ AttributeError("'Series' object has no attribute 'c'", 'occurred at index b')
Traceback: --------- File "/opt/conda/lib/python3.6/site-packages/dask/dataframe/utils.py", line 137, in raise_on_meta_error yield File "/opt/conda/lib/python3.6/site-packages/dask/dataframe/core.py", line 3477, in _emulate return func(*_extract_meta(args, True), **_extract_meta(kwargs, True)) File "", line 2, in ddf.map_partitions(lambda df : df.apply(lambda x : elementsearch((x.b,x.c),axis=1))) File "/opt/conda/lib/python3.6/site-packages/pandas/core/frame.py", line 6014, in apply return op.get_result() File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 318, in get_result return super(FrameRowApply, self).get_result() File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 142, in get_result return self.apply_standard() File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 248, in apply_standard self.apply_series_generator() File "/opt/conda/lib/python3.6/site-packages/pandas/core/apply.py", line 277, in apply_series_generator results[i] = self.f(v) File "", line 2, in ddf.map_partitions(lambda df : df.apply(lambda x : elementsearch((x.b,x.c),axis=1))) File "/opt/conda/lib/python3.6/site-packages/pandas/core/generic.py", line 4376, in __getattr__ return object.__getattribute__(self, name) [/code] Я отправил этот вопрос в Stack Overflow, но у меня это не сработало: В Dask DataFrame.apply() получение n строк со значением 1 до обработки фактических строк. Как я могу решить эту проблему?>