I am parsing data from an Excel file that has extra white space in some of the column headings.
When I check the columns of the resulting dataframe, with df.columns
, I see:
Index(['Year', 'Month ', 'Value'])
^
# Note the unwanted trailing space on 'Month '
Consequently, I can't do:
df["Month"]
Because it will tell me the column is not found, as I asked for "Month", not "Month ".
My question, then, is how can I strip out the unwanted white space from the column headings?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…