Error for adding columns in dataframe

I am getting Key error. Can some one suggest the alternative way?
Screenshot 2021-06-30 214458

if u can provide a link of ur notebook…I might able to understand as getting minimal info from the screenshot

Sure, here it is

hi, I just ran the notebook…didnt get any error…the cell seems to be running fine

For me, it is not allowing me to add columns in dataframe.

Try restarting the runtime and running all cells from top again. Let me know if you still get an issue.

I am getting the same error.

Where are you running the code? Local Computer? Binder or Colab?

Local computer, on jupyter notebook

Can you try updating the libraries(pandas and scikit learn) using !pip install scikit-learn pandas --upgrade

I updated the libraries but still same error.

Strange, it is running in Colab, can you try and use Colab?

Sure I will do that. Thankyou.

1 Like

The issue seems with your local environment setup. Your code syntax has no issue.

Yes, the same error occurred in the Linear Regression so I had to add each columns separately.