Reputation: 2500
I have the below function which works well if i just do a print of the iv fucntion, and it shows the outputs appearing on my screen.
However if i run the apply function and try to populate the output in a new column, it just populates None. Can you advise what is missing here please
def myfunc(row):
try:
iv(row['Close_x'], row['Close_y'], row['Strike'], row['TTE_x'], 0.0, flag='c')
except BelowIntrinsicException as bie:
print("bieError on row", row.name)
except ZeroDivisionError as zde:
print("zdeError on row", row.name)
except ValueError as ve:
print("veError on row", row.name)
df['IV_calls'] = df.apply(myfunc,axis=1)
Upvotes: 0
Views: 20
Reputation: 71
Your function has no return statement, hence it returns None.
Upvotes: 2