pandas dataframe column name: remove special character

后端 未结 2 886
粉色の甜心
粉色の甜心 2021-01-04 17:09

Some joker made a Lotus database/applet thingy for tracking engineering issues in our company. The joke is that the key piece of information was named with a special charac

相关标签:
2条回答
  • 2021-01-04 17:42

    use str.replace:
    df.columns=df.columns.str.replace('#','')

    You can check this in the documentation.

    0 讨论(0)
  • 2021-01-04 17:56

    Instead we can use lamda functions for removing special characters in the column

    df2=df1.rename(columns=lambda x:x.strip('*'))

    0 讨论(0)
提交回复
热议问题