How to Deal With Missing Data In Python Pandas (20+ Examples!)
🧠 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-automations-4579 Dealing with missing values is a critical step in any data analysis or machine learning pipeline. In this hands-on tutorial, you’ll learn how to identify, analyze, and clean missing data in Python using Pandas—with over 20 real-world examples and use cases! Code: https://ryanandmattdatascience.com/pandas-handle-missing-data/ 🚀 Hire me for Data Work: https://ryanandmattdatascience.com/data-freelancing/ 👨💻 Mentorships: https://ryanandmattdatascience.com/mentorship/ 📧 Email: [email protected] 🌐 Website & Blog: https://ryanandmattdatascience.com/ 🖥️ Discord: https://discord.com/invite/F7dxbvHUhg 📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan 📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg 🍿 WATCH NEXT Python Pandas Playlist: https://www.youtube.com/playlist?list=PLcQVY5V2UY4KvHRJ-awaxAPzFGdZ8yN6D Pandas Filter Multiple Conditions: https://youtu.be/2P--rjal30Y Pandas Apply: https://youtu.be/unthMgpKDsc Pandas Interpolation: https://youtu.be/BJHwPeRvyPE In this comprehensive Python Pandas tutorial, we dive deep into handling null values and missing data in your dataframes. Null values are one of the most common challenges when working with real-world datasets, and knowing how to identify, filter, fill, and remove them is essential for any data analyst or data scientist. We start by showing you how to identify null values using methods like `isnull()`, `isna()`, `notnull()`, and `info()`. You'll learn the important difference between `size()` and `count()` when dealing with missing data, and how to quickly spot null values in your datasets. From there, we cover filtering techniques so you can isolate rows based on null conditions using both single and multiple filters with AND and OR logic. Next, we explore sorting dataframes with null values and show you how to position them at the top or bottom of your sorted results. Then we move into data cleanup strategies, including how to remove rows or columns with missing values using `dropna()` and threshold parameters. But removing data isn't always the answer, so we spend significant time on filling strategies including forward fill, backward fill, filling with specific values, strings, statistics like mean and median, and even interpolation methods. We also demonstrate advanced techniques like using `replace()`, `mask()`, and `where()` functions, plus custom logic with conditional statements inside your fill operations. By the end of this video, you'll have multiple approaches for handling null values in Pandas and be able to choose the right strategy for your specific data cleaning needs. All code examples are available on my website linked in the description below. TIMESTAMPS 00:00 Introduction to Handling Null Values 01:04 Importing Libraries & Creating DataFrame 02:00 Identifying Null Values with isnull() 03:02 Using isna() Method 03:55 Using notnull() and notna() 05:17 Counting Missing Values 06:02 Filtering Based on Null Values 08:15 Sorting with Null Values 10:00 Removing Rows with Null Values 12:00 Removing Columns with Null Values 13:00 Filling Null Values with Specific Values 14:40 Filling Null Values with Strings 15:40 Forward Fill Method 17:02 Backward Fill Method 18:00 Group By with Fill Methods 19:00 Filling with Statistics (Mean/Median) 21:00 Interpolation Method 23:00 Using the Replace Function 26:00 Using Mask for Null Values 27:00 Using Where for Null Values 28:40 Custom Logic with Fill NA 31:00 Recap & Conclusion OTHER SOCIALS: Ryan’s LinkedIn: https://www.linkedin.com/in/ryan-p-nolan/ Matt’s LinkedIn: https://www.linkedin.com/in/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.
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.