Last answered:

14 Jun 2022

Posted on:

10 Jun 2022


dummies drop income <=50K has an error

When I ran this line of code:

train_dummies = train_dummies.drop([Income_ <=50K'], axis=1)

I got an error saying there is no such variable. I looked up all the dummy variables and actually only "Income_ >50K" exists. Can you please help? Thanks.

1 answers ( 0 marked as helpful)
Posted on:

14 Jun 2022


What comes to my mind is that you may have already run the cell that dropped the variable, so if you run it again, it is going to spill out an error. Please make sure to restart the kernel and try again.
Another possibility is that you set the parameter drop_first to be True instead of False.

Hope this helps!

Nikola, 365 Team

Submit an answer