Renaming columns in pandas

前端 未结 27 2540
野性不改
野性不改 2020-11-21 07:05

I have a DataFrame using pandas and column labels that I need to edit to replace the original column labels.

I\'d like to change the column names in a DataFrame

27条回答
  •  梦如初夏
    2020-11-21 07:20

    Since you only want to remove the $ sign in all column names, you could just do:

    df = df.rename(columns=lambda x: x.replace('$', ''))
    

    OR

    df.rename(columns=lambda x: x.replace('$', ''), inplace=True)
    

提交回复
热议问题