Pandas shows SettingWithCopyWarning after train_test_split

Viewed 2332

I'm trying to manipulate a dataframe that I received from Sci-Kit Learn's train_test_split operation. The system gives me the following:

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py:179: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame

The following raises the warning on my system:

import pandas as pd
from sklearn.model_selection import train_test_split
X=pd.DataFrame({'A':[2,5,7,8,9],'B':[2,5,3,51,5]})
(Xt,Xv)=train_test_split(X)
Xt.iloc[0,0]=6

I use the following versions:

python: '3.6.1 (default, Jun 26 2017, 19:29:26) \n[GCC 4.9.2]'

pandas: 0.20.3

sklearn: 0.18.2

3 Answers
Related