Excel SUMIFS, COUNTIFS & AVERAGEIFS in PYTHON (Pandas Library)
👉 Explore All My Excel Solutions: pythonandvba.com/solutions
𝗗𝗘𝗦𝗖𝗥𝗜𝗣𝗧𝗜𝗢𝗡
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
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]:
► bit.ly/3hNtkJD
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
👩💻 𝗦𝘂𝗺𝗜𝗳𝘀 𝗲𝘅𝗺𝗮𝗽𝗹𝗲:
import pandas as pd # pip install pandas
df = pd.read_csv('raw.githubusercontent.com/mwa...)
Sum of all tips on Sunday's during Dinner Time
day = 'Sun'
time = 'Dinner'
sumifs = df.query('day == @day & time == @time')['tip'].sum()
sumifs
𝗧𝗢𝗢𝗟𝗦 𝗔𝗡𝗗 𝗥𝗘𝗦𝗢𝗨𝗥𝗖𝗘𝗦
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🆓【𝗙𝗥𝗘𝗘】Excel Add-in (𝗠𝘆𝗧𝗼𝗼𝗹𝗕𝗲𝗹𝘁): pythonandvba.com/mytoolbelt
📊 Dashboard Excel Add-In (𝗚𝗿𝗮𝗳𝗹𝘆): pythonandvba.com/grafly
🎨 Cartoon Charts Excel Add-In (𝗖𝘂𝘁𝗲𝗣𝗹𝗼𝘁𝘀): pythonandvba.com/cuteplots
🤪 Fun Emoji Excel Add-In (𝗘𝗺𝗼𝗷𝗶𝗳𝘆): pythonandvba.com/emojify
📑 Excel Templates: pythonandvba.com/go/excel-tem...
🎓 My Courses: pythonandvba.com/go/courses
📚 Books, Tools, and More: pythonandvba.com/resources
𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🔗 LinkedIn: / sven-bosau
📸 Instagram: / codingisfun_official
💻 GitHub: github.com/Sven-Bo
💬 Discord: pythonandvba.com/discord
📬 Contact: pythonandvba.com/contact
☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲?
If you want to support this channel, you can buy me a coffee here: pythonandvba.com/coffee-donation
Пікірлер: 24
*Which Excel formula would you like to see next (in Python)?*
@stockinvestor1
3 жыл бұрын
growth or trend function from excel in python would be nice!
@CodingIsFun
3 жыл бұрын
@@stockinvestor1 Thanks for the video suggestion :)
@basalmustafa6531
2 жыл бұрын
how can we apply these formulas if we have same type of data but for different days in other columns e.g day1 column, day 2 column, .... up to dayN.
@CodingIsFun
2 жыл бұрын
@@basalmustafa6531 Can you perhaps elaborate on what it is you're actually trying to achieve? Please provide some additional info. Thanks!
@dheerajrathore5077
2 жыл бұрын
anything where we can use something like =countifs(sheet2!A:A,A1) where a1 is in different sheet
Thank you very much, as always you deliver beyond our expectations.
@CodingIsFun
3 жыл бұрын
Thank you! ❤
your tutorials are of great use
@CodingIsFun
3 жыл бұрын
Thank you for watching the video & your comment. Glad to hear that you find the tutorials useful 😃
Short crisp precise thanks alot making excel automation more fun
@CodingIsFun
3 жыл бұрын
A pleasure, thanks for watching!
Great Buddy! Speaking from Brasil. Thanks for taking your time sharing your knowledge!
@CodingIsFun
3 жыл бұрын
A pleasure, thanks for watching! Greetings to Brasil ❤😃
Excellent presentation. Now, question is how would you present the results in a nice report simular to the attached excel formula sheet ?
@CodingIsFun
2 жыл бұрын
Thank you! That is up to you. As you have already the data in a pandas dataframe, you might want to plot the data. Here is a video on how to insert Python charts into Excel: 👉 kzread.info/dash/bejne/ZnemvLeDpM3Am8Y.html Happy Coding!
What if I want the columns that displays the sumifs, countifs and averageifs in the raw dataset? How can I perform it?
@CodingIsFun
Жыл бұрын
You could do something similar like I did here: kzread.info/dash/bejne/c3yHm5RufJuwhs4.html Use Xlwings to export the dataframe to the same workbook. I hope it helps! Happy Coding!
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).
@CodingIsFun
2 жыл бұрын
Thanks for watching the video. Like I have shown at 1:49min?
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
@CodingIsFun
Жыл бұрын
Thank you for watching the video. Your questions are great, but finding the time to answer them is difficult. Kindly understand that I receive many requests for individual solutions or modifications. That said, you might want to join our Discord server ( pythonandvba.com/discord ) and post your question there. Thanks for your understanding. Happy Coding!