New to using Python. I'm loading a csv file into a pandas dataframe - I then want to amend one of the column headers as shown below.
Loading csv file:
df = (pd.read_csv(file, sep=',', error_bad_lines=False, index_col=False, encoding='cp1252', low_memory=False,
dtype={'ID':'string',
'Address':'string',
'Postcode / Zipcode':'string')
Can't get this rename header code to work. When I print the df the column name remains unchanged.
df.rename(columns={"Postcode / Zipcode" : "Postal Code"})
There are 4 csv files that I will be loading using a loop and the name of the column will vary for each file.