pandas rename multiple columns code example
Example 1: rename multiple pandas columns with list
for j in range(len(df.columns)):
old = df.columns[j]
new = new_columns[j]
df = df.rename(columns = {old:new})
Example 2: pandas rename multiple columns
# df is a pandas DataFrame
for col_name in df.columns:
# you can specify conditions if you need
# to change the name of some column only
df = df.rename(columns = {col_name:new_col_name}