How to deal with SettingWithCopyWarning?

I’m trying to work with a basic decision tree in python but can’t figure out how to get rid of this error message. Full error message: See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._setitem_with_indexer(indexer, value) dhcp-ccc-7057:kaggle Hyuckin$ python titanic.py titanic.py:16: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame The code that causes the error: train[“Sex”][train[“Sex”] == “male”] = 0 I looked at the documentation and tried: train[“Sex”].loc[train[“Sex”] == “male”] = 0 but that led to the same error. The error occurs in both python 2.7 and 3.5


Link to Full Article: How to deal with SettingWithCopyWarning?

Pin It on Pinterest

Share This

Join Our Newsletter

Sign up to our mailing list to receive the latest news and updates about homeAI.info and the Informed.AI Network of AI related websites which includes Events.AI, Neurons.AI, Awards.AI, and Vocation.AI

You have Successfully Subscribed!