df = df.rename(columns={'oldName1':'newName1','oldName2':'newName2'})# Or rename the existing DataFrame (rather than creating a copy)
df.rename(columns={'oldName1':'newName1','oldName2':'newName2'}, inplace=True)
# import pandas libraryimport pandas as pd
# create pandas DataFrame
df = pd.DataFrame({'team':['India','South Africa','New Zealand','England'],'points':['10','8','3','5'],'runrate':['0.5','1.4','2','-0.6'],'wins':['5','4','2','2']})# print the column names of DataFrameprint(list(df))# rename the column names of DataFrame
df.rename(columns={'points':'total_points','runrate':'run_rate'}, inplace=True)# print the new column names of DataFrameprint(list(df))
In [11]: df['n'].replace({'a':'x','b':'y','c':'w','d':'z'})
Out[11]:0 z
1 x
2 y
3 w
4 w
5 x
6 z
7 y
Name: n, dtype:object
In [12]: df['n']= df['n'].replace({'a':'x','b':'y','c':'w','d':'z'})