首页 > 解决方案 > 迭代存储由 SelectKBest 算法选择的特征的数组时出现 Keyerror 1 问题

问题描述

我收到了这个错误

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine._get_loc_duplicates()

KeyError: 1

while循环抛出一个数组

kbest_feature_corre

i = 0
while i < len(kbest_feature_corre):
    print(kbest_feature_corre[i])
    i += 1

数组看起来像这样

             Specs       Score
16    Predictor 17         inf
40    Predictor 41         inf
41    Predictor 42         inf
102  Predictor 103         inf
103  Predictor 104         inf
105  Predictor 106         inf
107  Predictor 108         inf
120  Predictor 121         inf
121  Predictor 122         inf
122  Predictor 123         inf
123  Predictor 124         inf
124  Predictor 125         inf
125  Predictor 126         inf
126  Predictor 127         inf
127  Predictor 128         inf
128  Predictor 129         inf
129  Predictor 130         inf
130  Predictor 131         inf
131  Predictor 132         inf
144  Predictor 145         inf
145  Predictor 146         inf
146  Predictor 147         inf
147  Predictor 148         inf
148  Predictor 149         inf
149  Predictor 150         inf
150  Predictor 151         inf
151  Predictor 152         inf
152  Predictor 153         inf
153  Predictor 154         inf
154  Predictor 155         inf
410  Predictor 411  113.389284
371  Predictor 372  107.523782
316  Predictor 317  105.745269
..             ...         ...

我想打印数组的所有结果,我找不到这里出了什么问题:/数组存储了应用 SelectKBest 算法进行特征选择的结果。

标签: pythonpandas

解决方案


推荐阅读