mrdbourke / zero-to-mastery-ml

All course materials for the Zero to Mastery Machine Learning and Data Science course.
https://dbourke.link/ZTMmlcourse
2.71k stars 3.31k forks source link

inplace = True in AI/ML course #91

Open CruIIer opened 2 weeks ago

CruIIer commented 2 weeks ago

https://academy.zerotomastery.io/courses/complete-machine-learning-and-data-science-bootcamp-2020/lectures/12693715

In this section we are doing the inplace=True. It works but it hits with Warning image

DarkDk123 commented 1 week ago

It's a FutureWarning

Because you're performing "Chained Indexing", and it has inherently unpredictable results (may return a view or copy)

So it's suggested by pandas to modify DataFrames directly, not on view-or-copy,

Instead, You can use this car_sales_missing.fillna({"Odometer": car_sales_missing["Odometer"].mean()}, , inplace=True)

This here :

image