raise KeyError(f“None of [{key}] are in the [{axis_name}]“)KeyError: “None of [Index([‘age.in.y

created at 06-26-2022 views: 22

problem

raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['age.in.years'], dtype='object')] are in the [columns]"

solution

train_score = sc.scorecard_ply(train2woe, card_dict, print_step=0)
train2woe 
      age.in.years_woe  ...  status.of.existing.checking.account_woe
0           -0.194156  ...                                 0.614204
1            0.528844  ...                                 0.614204
2           -0.194156  ...                                -1.176263
6           -0.194156  ...                                -1.176263
7           -0.563689  ...                                 0.614204

card_dict 
35  age.in.years  [-inf,26.0)   -20.0
36  age.in.years  [26.0,35.0)    -2.0
37  age.in.years  [35.0,40.0)    21.0
38  age.in.years   [40.0,inf)     7.0,

The output data shows that the problem caused by the inconsistent column names of the two dataframe! Just make the column names of the data in the two dataframe formats consistent!

created at:06-26-2022
edited at: 06-26-2022: