Pandasdrill

Level 6: From Excel and SQL Exercise 81 of 102

Excel SUMIFS: a total with two conditions

A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.

The task

The Excel formula would be `SUMIFS(amount, status, "completed", amount, ">=50")`. Return the total `amount` of orders that are completed and worth at least 50, as a single number.

What this exercise teaches

Each comparison gives a boolean Series, and & keeps the rows where both are True. The parentheses are required because & binds tighter than == and >=. loc[mask, "amount"] picks the amounts of those rows and sum() adds them.

A hint if you get stuck

Build one True/False mask per condition, put each in parentheses and join them with &. Then pick the column and add it up.

Try it now, free, no account needed

Your first 8 exercises on Pandasdrill are free. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro unlocks every exercise, timed mode and the certificate.

Open this exercise

More exercises in From Excel and SQL