0

I am working from this Kaggle notebook :

https://www.kaggle.com/kitakoj18/exploring-wine-descriptions-with-nlp-and-kmeans

Please see in [15] section where the notebook is trying to run :

variety_df['cluster'] = kmeans.labels_

This results in the error message :

/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  """Entry point for launching an IPython kernel.

How can this be fixed? I can't make sense of it from the docs.

Thank you.

Simon Kiely
  • 5,880
  • 28
  • 94
  • 180
  • How is created `variety_df` ? Maybe need `.copy()` like `variety_df = df[df.A == 1].copy()` – jezrael Sep 18 '18 at 11:32
  • this is not an error but a warning, and agree with @jezrael, looks like `variety_df` is a view of a dataframe, not a dataframe on its own – Yuca Sep 18 '18 at 11:38

0 Answers0