You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often want to use a "UDF" on a DataFrame where some scalar values can be supplied programmatically.
In Pandas, I can do:
import pandas as pd
pdf = pd.DataFrame({'val': [0, 1, 2]})
def func(x, A, B):
return x['val'] + A - B
pdf.apply(func, axis=1, args=(1, 2))
0 -1
1 0
2 1
With cuDF, I can't see a way to pass scalar args to func:
import cudf
cdf = cudf.from_pandas(pdf)
cdf.apply(func, axis=1, args=(1, 2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rgelhausen/conda/envs/dsql/lib/python3.8/site-packages/cudf-21.12.0a0+252.ga694162f09-py3.8-linux-x86_64.egg/cudf/core/dataframe.py", line 4237, in apply
raise ValueError("args and kwargs are not yet supported.")
ValueError: args and kwargs are not yet supported.
As a workaround, I can do something like:
A = 1
B = 2
def func(x):
return x['val'] + A - B
cdf.apply(func)
And if I want different values for A and B, I can update them then apply func again.
The text was updated successfully, but these errors were encountered:
I often want to use a "UDF" on a DataFrame where some scalar values can be supplied programmatically.
In Pandas, I can do:
With cuDF, I can't see a way to pass scalar args to func:
As a workaround, I can do something like:
And if I want different values for A and B, I can update them then apply func again.
The text was updated successfully, but these errors were encountered: