xxxxxxxxxx
[df.rename(columns={df.columns[j]: COLUMNS[j]}, inplace=True) for j in range(df.shape[1])]
xxxxxxxxxx
import pandas as pd
# Create a DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
# Rename multiple columns
df.rename(columns={'A': 'NewNameA', 'B': 'NewNameB'}, inplace=True)
# Print the DataFrame with renamed columns
print(df)
xxxxxxxxxx
for j in range(len(df.columns)):
old = df.columns[j]
new = new_columns[j]
df = df.rename(columns = {old:new})
xxxxxxxxxx
# 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}
xxxxxxxxxx
df['column name'] = df['column name'].replace(['1st old value','2nd old value', ],'new value')