Rename specific column(s) in pandas

I've got a dataframe called data. How would I rename the only one column header? For example gdp to log(gdp)?

    data =
        y  gdp  cap
    0   1    2    5
    1   2    3    9
    2   8    7    2
    3   3    4    7
    4   6    7    7
    5   4    8    3
    6   8    2    8
    7   9    9   10
    8   6    6    4
    9  10   10    7
    data.rename(columns={'gdp':'log(gdp)'}, inplace=True)

The rename show that it accepts a dict as a param for columns so you just pass a dict with a single entry.

Also see related

From: stackoverflow.com/q/19758364

Back to homepage or read more recommendations: