Answer the question
In order to leave comments, you need to log in
How to make a calculated field in a DataFrame by condition?
For example, a calculated field
The problem is that m can be equal to 0. It is necessary that when m = 0, then the value of the calculated field is equal to 0.
How to do this?
df['new'] = df.n / df.m
Answer the question
In order to leave comments, you need to log in
Describe a function that takes n and m and divides n by m. If m==0 returns 0.
And then just call this function with your arguments:
df['new'] = foo(df.n, df.m)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question