Hello all,
My main concern is the SettingWithCopyWarning I get starting from Cell 30. I have tried using dataframe.copy() and .loc as suggested by the warning message but they do not work. From the result it seems the code worked as intended, but I’m still wondering what caused the issue.
Any other feedback is welcome too of course!
Thanks!
Basics.ipynb (161.0 KB)Click here to view the jupyter notebook file in a new tab
1 Like
Hello @changni924 Congratulations on finishing the project, and thanks for sharing your project.
To avoid above warnings, you might need to create a copy after dropping missing values. The .dropna
seems like it is not returning a deep copy.
# Drop columns with less than 500 non-null values
combined_updated = combined.dropna(thresh = 500, axis = 1).copy()
combined_updated.info()
Check out the following:
Shallow Copy Vs Deep Copy
[adam-niescioruk-e7dVRT4tL9A-unsplash]
In this article, I’m going to show you 3 ways of copying Dataframes in Pandas, explain how they are all different and tell you when you should use either.
Equals (df1 = df)
When we assign a DataFrame to a new variable using =, we are not creating a new copy of the DataFrame. We are merely adding a new name to call the same object. The below example will help you to understand it better. Notice that the id of both df and df1 objects are the same. So wheth…