Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inplace = True in AI/ML course #91

Open
CruIIer opened this issue Jun 13, 2024 · 2 comments
Open

inplace = True in AI/ML course #91

CruIIer opened this issue Jun 13, 2024 · 2 comments

Comments

@CruIIer
Copy link

CruIIer commented Jun 13, 2024

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
Copy link

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

@simkimsia
Copy link

simkimsia commented Jul 18, 2024

@DarkDk123 thank you. This should be updated in the course itself. @mrdbourke ?

by the way, i am using pandas 2.2.2 the correct line should be

car_sales_missing.fillna({"Odometer": car_sales_missing["Odometer"].mean(numeric_only=True)}, inplace=True)

@DarkDk123 forgot about numeric_only=True and has an extra ,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants