How to add a suffix (or prefix) to each column name?

前端 未结 6 2090
-上瘾入骨i
-上瘾入骨i 2020-11-28 23:12

I want to add _x suffix to each column name like so:

featuresA = myPandasDataFrame.columns.values + \'_x\'

How do I do this? A

6条回答
  •  迷失自我
    2020-11-28 23:51

    I haven't seen this solution proposed above so adding this to the list:

    df.columns += '_x'
    

    And you can easily adapt for the prefix scenario.

提交回复
热议问题