add a string prefix to each value in a string column using Pandas

后端 未结 5 752
梦如初夏
梦如初夏 2020-11-28 03:05

I would like to append a string to the start of each value in a said column of a pandas dataframe (elegantly). I already figured out how to kind-of do this and I am currentl

5条回答
  •  时光说笑
    2020-11-28 03:30

    You can use pandas.Series.map :

    df['col'].map('str{}'.format)
    

    It will apply the word "str" before all your values.

提交回复
热议问题