5 Ways to Find the Mean, Median, and Mode in Python

Опубликовано: 22 Март 2026
на канале: Ryan & Matt Data Science
4,396
78

🧠 Don’t miss out! Get FREE access to my Skool community — packed with resources, tools, and support to help you with Data, Machine Learning, and AI Automations! 📈 https://www.skool.com/data-and-ai-aut...

Mean, Median, and Mode are all super common statistics that people look at when looking at datasets within Python. In this video, we will look at 5 different approaches on how we can find these datapoints.


🚀 Hire me for Data Work: https://ryanandmattdatascience.com/da...
👨‍💻 Mentorships: https://ryanandmattdatascience.com/me...
📧 Email: [email protected]
🌐 Website & Blog: https://ryanandmattdatascience.com/
🖥️ Discord:   / discord  
📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan
📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg

🍿 WATCH NEXT
Statistics for Data Science Playlist:    • Statistics for Data Science  
Python STD and Variance:    • How to Calculate Standard Deviation & Vari...  
Python Z Score:    • Python Z-Score Explained: Code Example wit...  
Python Quantiles:    • Understanding Quantiles in Python: A Step-...  


In this comprehensive tutorial, I break down mean, median, and mode—the fundamental statistics everyone should know—and show you exactly how to calculate them using Python. We start with manual calculations to understand the core concepts, then move through multiple methods using NumPy, statistics libraries, and pandas DataFrames to make your data analysis workflow more efficient.

Throughout this video, I walk you through 16 practical examples, starting with basic manual calculations and progressing to more advanced techniques. You'll learn how to find mean using simple summation and division, tackle median with both even and odd number sets using floor division, and master mode by working with frequency dictionaries and the Counter class from collections.

I also demonstrate how to work with pandas DataFrames—an essential skill for real-world data exploration—and show you the most efficient one-line methods for each statistic. As a bonus, the final section covers how to create flexible functions using *args, allowing you to calculate mean, median, and mode with unlimited parameters. By the end of this tutorial, you'll have multiple tools in your arsenal for statistical analysis in Python and know exactly when to use each method for maximum efficiency.

TIMESTAMPS
00:00 Introduction to Mean, Median, and Mode
01:00 Setting Up Imports and Data
02:30 Calculating Mean Manually
03:02 Mean with NumPy
03:40 Mean with Statistics Library
03:55 Mean with Pandas DataFrame
04:50 Introduction to Median
06:00 Calculating Median Manually
08:15 Median with NumPy and Statistics
10:00 Median with Pandas DataFrame
11:00 Introduction to Mode
12:00 Calculating Mode with Counter
13:30 Mode Without List Comprehension
15:30 Mode with Statistics Library
16:00 Mode with Pandas DataFrame
18:59 Advanced: Args with Mean Function
20:30 Advanced: Args with Median Function
24:00 Debugging Median Function
27:00 Advanced: Args with Mode Function

OTHER SOCIALS:
Ryan’s LinkedIn:   / ryan-p-nolan  
Matt’s LinkedIn:   / matt-payne-ceo  
Twitter/X: https://x.com/RyanMattDS

Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.

Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.

*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.