迭代存储SelectKBest algori选择的功能的数组时出现Keyerror 1问题

2024-06-14 01:54:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我犯了这个错误

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

循环时抛出一个数组

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算法进行特征选择的结果


Tags: inpandasgetindex错误数组predictorloc