Drop rows with missing values with pandas dropna // Python pandas dropna, subset, axis, thresh

preview_player
Показать описание
Learn how to drop rows with missing values using the Python pandas dropna method. In this video, I'll show you how to drop rows with a missing value in any column as well as how to only drop rows that are missing all column values. Then level up by using pandas to drop missing values in a specific column using the subset property. You can also use pandas dropna subset to drop based on multiple columns by passing a list to subset. I'll demonstrate how to drop columns with missings as well, though using how='any' or how='all' doesn't work as well for columns. Instead, use the property thresh to drop based on a threshold number of missing values. Using Python pandas dropna thresh is a great way to clean out columns with too many missings before doing machine learning problems. Finally, make your changes permanent by switching the pandas dropna inplace property to True. Check out this and other videos in my Pandas Tips series to experience my pandas tutorial and level up your Python pandas programming skills.

0:00 Introduction
0:23 Set up and load data
1:25 Drop rows with ANY missings
2:36 Drop rows with ALL missings
3:30 Level UP! Drop based on one column (subset)
4:38 Drop based on multiple columns
5:43 Drop COLUMNS with missings
7:02 Threshold for missings (thesh)
9:31 Save changes with inplace
10:20 Conclusion

💻 Github CODE & Data 💻

🎥 Related VIDEOS 🎥

📖 BOOKS about pandas from my Amazon Storefront 📖

☕ Buy me a COFFEE ☕
If you have enjoyed the content presented in this video and are able, consider buying a virtual cup of coffee to keep my channel going!

#python #pandas #pythonprogramming
Рекомендации по теме
Комментарии
Автор

Great presentation! You showed how really versatile dropna with its different parameter options. Thank you.

ziggle
Автор

Very useful .. straight direct ... clean and clear .. I like it

maghedrizk
Автор

What a great video! Thank you so much for your explanation!

minhnguyen-omcb
Автор

Wow such a nice way to present this topic in data science. Thank you !!

yellowmathboard
Автор

Mam, im also programmer. I have subscribed your channel

easyprogramminglessons
Автор

How do you tell if a dataset is <5% values where it justifies the use of dropna vs using an imputated value to replace instead?

Chilli_Tea
Автор

I have a dataset that has [x] in two rows. I have tried different ways to remove these rows but none have worked. I have also tried replacing the values with NaN and tried the dropna function but this has not worked. Does anyone know how I can drop these rows?

henry-zhrv