This stripes out the unwanted white space from the column headings when we parse from an excel file with multiple sheets.
df = {key: sheet.rename(columns=lambda x: x.strip()) for key, sheet in pd.read_excel(filename).items()}
But if I want to parse from a csv file instead, and not from an excel with sheets, how do I do this?
df = pd.read_csv(fname, sep=";", header=0, encoding="iso-8859-1", error_bad_lines=False)
keys_df = df.rename(columns={lambda x: x.strip()})
doesn't seem to work.
I want to do it in dictionary keys, not a list.
This question did not help me, as I want to create dictionary keys from the renamed columns.