Excel SUMIFS, COUNTIFS & AVERAGEIFS in PYTHON (Pandas Library)

preview_player
ะŸะพะบะฐะทะฐั‚ัŒ ะพะฟะธัะฐะฝะธะต

๐——๐—˜๐—ฆ๐—–๐—ฅ๐—œ๐—ฃ๐—ง๐—œ๐—ข๐—ก
โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€
This video will show you, how to perform the Excel functions: SumIf(s), CountIf(s) & AverageIf(s) in Python. In particular, we will be using the Pandas library & the query method.

๐Ÿ“ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€:
Download the files from the tutorial here [Google Drive]:

โ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธโ—ผ๏ธ
๐Ÿ‘ฉโ€๐Ÿ’ป ๐—ฆ๐˜‚๐—บ๐—œ๐—ณ๐˜€ ๐—ฒ๐˜…๐—บ๐—ฎ๐—ฝ๐—น๐—ฒ:
import pandas as pd # pip install pandas

# Sum of all tips on Sunday's during Dinner Time
day = 'Sun'
time = 'Dinner'
sumifs

๐—ง๐—ข๐—ข๐—Ÿ๐—ฆ ๐—”๐—ก๐—— ๐—ฅ๐—˜๐—ฆ๐—ข๐—จ๐—ฅ๐—–๐—˜๐—ฆ
โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€

๐—–๐—ข๐—ก๐—ก๐—˜๐—–๐—ง ๐—ช๐—œ๐—ง๐—› ๐— ๐—˜
โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€

โ˜• ๐—•๐˜‚๐˜† ๐—บ๐—ฒ ๐—ฎ ๐—ฐ๐—ผ๐—ณ๐—ณ๐—ฒ๐—ฒ?
ะ ะตะบะพะผะตะฝะดะฐั†ะธะธ ะฟะพ ั‚ะตะผะต
ะšะพะผะผะตะฝั‚ะฐั€ะธะธ
ะะฒั‚ะพั€

*Which Excel formula would you like to see next (in Python)?*

CodingIsFun
ะะฒั‚ะพั€

Short crisp precise thanks alot making excel automation more fun

sureshgoku
ะะฒั‚ะพั€

Thank you very much, as always you deliver beyond our expectations.

ermalgashimramori
ะะฒั‚ะพั€

Great Buddy! Speaking from Brasil. Thanks for taking your time sharing your knowledge!

wagnerbarbosa
ะะฒั‚ะพั€

what if I want to create a new column containing the sum for each Unique value in another column as opposed to summing only "Germany" for instance... say I want a column with a sum for every country listed (assuming the number of countries is too long to list).

davida
ะะฒั‚ะพั€

Excellent presentation.
Now, question is how would you present the results in a nice report simular to the attached excel formula sheet ?

edbull
ะะฒั‚ะพั€

What if I want the columns that displays the sumifs, countifs and averageifs in the raw dataset? How can I perform it?

SnkRobertoHz
ะะฒั‚ะพั€

Hi,

Is it possible to convert below the input

Customer_Name, Product_1, Price_1, Product_2, Price_2
Zayn, Milk, 30, Chocolate, 40
Peter, Cheese, 190, Oil, 80
Andrew, Coconut, 10, Milk, 60
Dwayne, Soya, 100, Butter, 120

to this output where the Product name should be ascending and it should also have its price in the next column

Customer_Name, Product_1, Price_1, Product_2, Price_2
Zayn, Chocolate, 40, Milk, 30
Peter, Cheese, 190, Oil, 80
Andrew, Coconut, 10, Milk, 60
Dwayne, Butter, 120, Soya, 100


Can you please help

hayathbasha