The following function: def func(x): for k in x['slices']: for j in k: print(x['low'].iloc[j]) applied in the following manner works: func(test) but as f
Solution 1:
define your function this way
def fun(slices):
return [df.low.loc[s].tolist() for s in slices]
And apply over the slices column
df['slices_low'] = df.slices.apply(fun)
df
Share
Post a Comment
for "Python Pandas: Function Doesn't Work When Used With Apply()"
Post a Comment for "Python Pandas: Function Doesn't Work When Used With Apply()"