Skip to content
Advertisement

Multiplying pandas columns based on multiple conditions

I have a df like this

JavaScript

I want a output like below

JavaScript

The goal is calculate column C by mulytiplying A and B only when the count value is “yes” but if the column People values are same that is yes for dia and no for also dia , then we have to calculate for the count value “no”

I tried this much so far

JavaScript

But not able to achieve the goal, any idea how can I achieve the output

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement