I am trying to use cuDF row_apply to calculate a new column according to other rows.
For a single row, it works well with the following script
filteredhlcdf.loc[(filteredhlcdf.ddate == %%Ddate%%) & (filteredhlcdf.sstart == %%sTime%%) & (filteredhlcdf.ttime <= %%etime%%) & (filteredhlcdf.H > %%ustep%%) , "ttime" ].min()
where the variable between %% are substituted by constants.
However, when I try to use row apply as follows, it generates an error
crossappliedcdf = cudf.from_pandas(crossapplieddf)
filteredhlcdf = cudf.from_pandas(filteredhldf)
def rowcal(ddate: int, stime: int, etime: int, usteps: float, dsteps: float, ctime: int, creturn: float):
#def rowcal(ddate: float, stime: float, etime: float, usteps: float, dsteps: float, ctime: int, creturn: float, kwarg1: int):
for i, (tddate, tstime, tetime, tusteps, tdsteps) in enumerate(zip(ddate, stime, etime, usteps, dsteps)):
ctime[i] = filteredhlcdf.loc[(filteredhlcdf.ddate == tddate) & (filteredhlcdf.sstart == tstime) & (filteredhlcdf.ttime <= tetime) & (filteredhlcdf.H > tusteps) , "ttime" ].min()
creturn[i] = tddate + tstime + tetime+ tdsteps
crossappliedcdf.apply_rows(rowcal, incols=['ddate', 'stime', 'etime','usteps','dsteps'], outcols=dict(ctime=np.int32, creturn=float), kwargs={})
I am sure the mistake occurs in the following line
ctime[i] = filteredhlcdf.loc[(filteredhlcdf.ddate == tddate) & (filteredhlcdf.sstart == tstime) & (filteredhlcdf.ttime <= tetime) & (filteredhlcdf.H > tusteps) , "ttime" ].min()
because the error disappeared after it is replaced by ctime[i] = tddate + tstime + tetime+ tdsteps