1In [4]: import pandas as pd
2In [5]: df = pd.DataFrame(columns=['A','B','C','D','E','F','G'])
3In [6]: df
4Out[6]:
5Empty DataFrame
6Columns: [A, B, C, D, E, F, G]
7Index: []
1df.rename(columns={"A": "a", "B": "b", "C": "c"},
2errors="raise", inplace=True)
3
1df_new = df.rename(columns={'A': 'a'}, index={'ONE': 'one'})
2print(df_new)
3# a B C
4# one 11 12 13
5# TWO 21 22 23
6# THREE 31 32 33
7
8print(df)
9# A B C
10# ONE 11 12 13
11# TWO 21 22 23
12# THREE 31 32 33
13
1>gapminder.columns = ['country','year','population',
2 'continent','life_exp','gdp_per_cap']
3