I am trying to remove the last several columns from a data frame.  However I get a syntax error when I do this:
db = db.drop(db.columns[[12:22]], axis = 1)
This works but it seems clumsy...
db = db.drop(db.columns[[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]], axis = 1)
How do I refer to a range of columns?
Steven Burnap's explanation is correct, but the solution can be simplified - just remove the internal parentheses:
db = db.drop(db.columns[12:22], axis = 1)
this way, db.columns[12:22] is a 'slice' of the columns array (actually index, but doesn't matter here), which goes into the drop method.
Syntax Error In Python When Trying To Refer To Range Of Columns