For some reason train\_test\_split, despite lengths being identical and indexes look the same, triggers this error.

```
from sklearn.model_selection import KFold

data = {'col1':[30.5,45,1,99,6,5,4,2,5,7,7,3], 'col2':[99.5, 98, 95, 90,1,5,6,7,4,4,3,3],'col3':[23, 23.6, 3, 90,1,9,60,9,7,2,2,1]} 
df = pd.DataFrame(data)

train, test = train_test_split(df, test_size=0.10)
X = train[['col1', 'col2']]
y2 = train['col3']

X = np.array(X)

kf = KFold(n_splits=3, shuffle=True)
for train_index, test_index in kf.split(X):
    X_train, y_train = X[train_index], y[train_index]

```

y is a pandas Series (same length as x).
x was a dataframe with about 20 numerical columns casted to numpy array.

For some reason train\_test\_split triggers the error despite the lengths being identical.

If i dont call train\_test\_split it works fine.

the last line triggering the error due to trying to index numpy array this way:
y[train\_ind]