0

In a Pandas dataframe (say df), I have the following column:

       company_id 
    1    QW5kcm9z 
    2    QXNzb2Np 
    3        QmVs 
    4    RGFub25l 
    5    RWNvdG9u 
    6    RmVycmVy 
    7    R2VuZXJh 
    8    SGVybw== 
    9    S2VsbG9n 
    10   TWFycw== 
    ...  ...

I'd like to create another colmun based on this column with "./Pics/" at the beginning and ".png" at the end, so the first value would be: ./Pics/QW5kcm9z.png

crocefisso
  • 793
  • 2
  • 14
  • 29

1 Answers1

1

Use:

df['new'] = './Pics/'+ df.company_id + '.png'
print (df)
   company_id                  new
1    QW5kcm9z  ./Pics/QW5kcm9z.png
2    QXNzb2Np  ./Pics/QXNzb2Np.png
3        QmVs      ./Pics/QmVs.png
4    RGFub25l  ./Pics/RGFub25l.png
5    RWNvdG9u  ./Pics/RWNvdG9u.png
6    RmVycmVy  ./Pics/RmVycmVy.png
7    R2VuZXJh  ./Pics/R2VuZXJh.png
8    SGVybw==  ./Pics/SGVybw==.png
9    S2VsbG9n  ./Pics/S2VsbG9n.png
10   TWFycw==  ./Pics/TWFycw==.png
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252