Below is a minimum reproducible example of what I'm trying to achieve with my custom function. The function works if I remove the if statement and second argument. I know the error is derived from the if statement, but I can't seem to figure out what the solution is.
df = pd.DataFrame({"odds":[100, -200, -400], "favorite":[0, 1, 1]})
def odd_bin_group_fn(odds, favorite):
if (odds <= -200 and favorite == 1):
return('large_favorite')
else:
return('other')
df['odd_bin'] = odd_bin_group_fn(df["odds"], df["favorite"])