Not able to drop a column in a pandas dataframe

Question:

I am a beginner in data analysis with python, and I am currently stuck on why I keep getting a key error even after looking up multiple sources on how to fix it. Here is a small sample of my data
(https://i.stack.imgur.com/X1N4q.png)

I have tried running this code:
SATdf.drop(['School ID'], axis=1, inplace= True) SATdf.drop(['Building Code'], axis=1, inplace = True)
However I keep getting this error:
(https://i.stack.imgur.com/1yd3j.png)
Same for building code.
I appreciate any pointers.

Asked By: Jase C

||

Answers:

Have you tried SATdf.drop(columns=['School ID','Building Code'], inplace= True) ?

Answered By: Rodrigo Guzman
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.