I'm trying to read in a data set and dropping the first two columns of the data set, but it seems like it is dropping the wrong column of information. I was looking at this thread, but their suggestion is not giving the expected answer. My data set starts with 6 columns, and I need to remove the first two. Elsewhere in threads it has the option of dropping columns with labels, but I would prefer not to name columns only to drop them if I can do it in one step.
df= pd.read_excel('Data.xls', header=17,footer=246) df.drop(df.columns[[0,1]], axis=1, inplace=True) But it is dropping columns 4 and 5 instead of the first two. Is there something with the drop function that I'm just completely missing?
df.columnsand make sure it looks like what you were expecting. Maybe the order got changed somewhere?df.reset_index()-- that converts index columns into regular columns.