0

how to replace itrerows function in pandas dataframe

for index, row in new_frame.iterrows():
    new_frame.at[index, 'image'] = ('{0}{1}_1.jpg'.format(image_folder, 
                                                           str(row.Code)))
hamza chenni
  • 146
  • 2
  • 18
  • 1
    Does this answer your question? [How to apply a list comprehension in Panda Dataframe?](https://stackoverflow.com/questions/62118556/how-to-apply-a-list-comprehension-in-panda-dataframe) – RichieV Sep 13 '20 at 13:41
  • No i didn't because i faild i try with itertuples : for row in new_frame.itertuples(): new_frame.at[row.index, 'image'] = ('{0}{1}_1.jpg'.format(image_folder, str(row.Code))) but i got an other probleme – hamza chenni Sep 13 '20 at 13:42

1 Answers1

2

You don't show any sample data, but it seems you could use

new_frame['image'] = image_folder + new_frame['Code'].astype(str) + '_1.jpg'

Assuming image_folder is a string

RichieV
  • 5,103
  • 2
  • 11
  • 24