Key Error: None of [Int64Index…] dtype='int64] are in the columns

前端 未结 5 2393
广开言路
广开言路 2020-12-17 16:49

I\'m trying to shuffle my indices using the np.random.shuffle() method, but I keep getting an error that I don\'t understand. I\'d appreciate it if someone could help me puz

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 17:18

    You created your scaled_inputs_all DataFrame using loc function, so it most likely contains no consecutive indices.

    On the other hand, you created shuffled_indices as a shuffle from just a range of consecutive numbers.

    Remember that scaled_inputs_all[shuffled_indices] gets rows of scaled_inputs_all which have index values equal to elements of shuffled_indices.

    Maybe you should write:

    scaled_inputs_all.iloc[shuffled_indices]
    

    Note that iloc provides integer-location based indexing, regardless of index values, i.e. just what you need.

提交回复
热议问题