12

I know to delete a column I can use df = df.drop('column_name', 1), but how would I remove a column just by indexing which column it is? As in without inserting the name?

Sorry if this question has been repeated I can't seem to find it

ghost
  • 309
  • 1
  • 2
  • 9

1 Answers1

20

You can delete column by index i

df.drop(df.columns[i], axis=1)

Adapted from duplicate question:

https://stackoverflow.com/a/20301769/3006366

Community
  • 1
  • 1
ode2k
  • 2,653
  • 13
  • 20