How to eliminate the NaN values of a DataFrame
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
It is always super hyper important to know how to deal with NaN values.
It can have a huge impact on your algorithm performance, especially in Machine Learning.
You will always need to think twice about how to deal with those NaN values.
The Pandas library has few methods that you can use to deal with those NaN values, such as:
- Backward fill
- Forward fill
- Interpolate value
- Replace
Backward fill
This method will take the next available value as present value if exists.
![](https://blogv2.thepythonyouneed.com/content/images/2021/08/image-5.png)
Forward fill
This method will take the previous available value as present value if exists.
![](https://blogv2.thepythonyouneed.com/content/images/2021/08/image-5.png)
Interpolate value
This method will try to estimate what is the value in-between two observations.
![](https://blogv2.thepythonyouneed.com/content/images/2021/09/image-12.png)
Replace
This method will replace NaN values with a specific value.
Here you are, all those articles will teach you how to apply a specific method to deal with NaN values.
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
Related Articles
Continue your learning journey with these related topics
Master Data Science in Days, Not Months 🚀
Skip the theoretical rabbit holes. Get practical data science skills delivered in bite-sized lessons – Approach used by real data scientist. Not bookworms. 📚