困惑为什么为什么在执行分组折叠操作时丢失一行数据时会再次出现
df = df.dropna(axis=0) ## row 2 has disappeared
groups = df['RaceId'] ## row 2 has indeed gone from groups indices
X = df[['Dlto', 'Penulto']]
y = df[['FinPos']]
gkf = GroupKFold(n_splits=2)
for train_index, test_index in gkf.split(X, y, groups=groups):
print("TRAIN:", train_index, "TEST:", test_index)
此时,第2行(已删除的Nan)会再次出现在火车或测试索引中,而最后一行尚未被拾取。
答案 0 :(得分:0)
我设法解决了我的误会。我不记得dropna似乎会修改索引,而实际上并没有删除和改组行。一旦我明白了,剩下的就说得通了