I have a dataframe that has two columns:
df
There are some scientific values like 0E-10
, I want create a new column such that:
df["new_col"]=df["fruits_ratio"]/(df["fruits_ratio"]+df["vegetables_ratio"])
But it give me an error like this:
DivisionByZero: [<class 'decimal.DivisionByZero'>]
Is there a way to either replace the 0-E10
values or how can I avoid the error?
Thanks
I think the float function will fix this for you float()
. Assign the entire column as floats since most are already.