Skip to content
Advertisement

How to use Excel’s SUMIF function in Pandas

I have a difficulty in calculating “total_sum.” If someone didn’t apply to subject, I expressed N/A. When total_sum is calculated, total_sum refer to Standard field and N/A is excluded. I’m not good at Python, So I don’t know how to calculate “total_sum”

JavaScript

Advertisement

Answer

Suppose this dataframe is the same as yours (with index of strings)

JavaScript

then you can apply .dot() of every .notna() subject values to the values of Standard

JavaScript

result :

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