Skip to content
Advertisement

how to replace itrerows function in pandas dataframe

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)))

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement