iPython笔记本“正在尝试从DataFrame的切片副本上设置一个值。请改用.loc [row_indexer,col_indexer] =值”

时间:2018-09-18 11:31:45

标签: python python-3.x pandas dataframe ipython

我正在使用此Kaggle笔记本工作:

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

请在[15]部分中查看笔记本试图运行的位置:

variety_df['cluster'] = kmeans.labels_

这将导致错误消息:

/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.

如何解决?我无法从文档中理解它。

谢谢。

0 个答案:

没有答案