Reputation: 1328
didnt see yet how it would be because i don't want to remember the names of the columns, also maybe my columns are integer, just dropping them by their position i'm interested in, any idea? No info on the documentation
Thank you so much
Update
For example:
del df[0,1,2,3] # Doesn't work
df.drop(df.columns[[0,1,2,3]], axis=1) # Doesn't work because it has a list instead of one column, i mean dropping multiple columns not just one
my DF:
help ... success
_links https://opendata.com/data... ... True
fields https://opendata.com/data... ... True
Upvotes: 3
Views: 2791
Reputation: 863741
Problem was original solution not working, because df
was list.
So first update as list and then cast to DataFrame for avoid it.
Then working correctly:
#remove columns by indexing
df1 = df1.drop(df1.columns[[0, 1, 3]], axis=1)
Upvotes: 3