Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)
edited by

I understand that to drop a column you use df.drop('column name', axis=1). Is there a way to drop a column using a numerical index instead of the column name?

1 Answer

0 votes
by (41.4k points)

  Simply drop multiple columns:

cols = [1,2,4,5,12]

df.drop(df.columns[cols],axis=1,inplace=True)

If you want to learn more about Pandas then visit this Python Course designed by the industrial experts.

 

 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...