I am running the following code:
df['diff']=np.where(df['fc']!=0,(df['ar']-df['fc'])/df['fc'],0)
It is returning a ZeroDivisionError. I'm not sure how that is happening when I am specifying to only run that formula if the denominator does not equal 0. If I run the below it works, but I don't want to cut out the rows where this is true:
df2=df[df['fc']!=0]
df2['diff']=(df['ar']-df['fc'])/df['fc']
edit to "specify clear goal": The desired output here would return 0 where the denominator is 0 and return the difference % where the denominator > 0.
Thanks you for the answer! works perfectly.