How do I remove columns starting from a certain index to another, I need to remove columns from 1950 to 2004?
I tried running this but it didn’t work
test = df.drop(df.iloc[:, 1:55], axis = 1)
How do I remove columns starting from a certain index to another, I need to remove columns from 1950 to 2004?
I tried running this but it didn’t work
test = df.drop(df.iloc[:, 1:55], axis = 1)
Assuming the column names are integers:
test = df.drop(list(range(1950,2005)), axis=1, errors='ignore')
For strings:
test = df.drop(list(map(str, range(1950,2005))), axis=1, errors='ignore')