I'm trying to:
Import a CSV of UPC codes into a dataframe. If the UPC code is 11 characters , append '0' to it. Ex: 19962123818 --> 019962123818
This is the code:
 #check UPC code length. If 11 characters, adds '0' before. If < 11 or > 13, throws Error
for index, row in clean_data.iterrows():
    if len(row['UPC']) == 11:
        row['UPC'] = ('0' + row['UPC'])
        #clean_data.set_value(row, 'UPC',('0' + (row['UPC']))
        print ("Edited UPC:", row['UPC'], type(row['UPC']))
    if len(row['UPC']) < 11 or len(row['UPC']) > 13:
        print ('Error, UPC length < 11 or > 13:')
        print ("Error in UPC:", row['UPC'])
        quit()
However, when I print the data, the original value is not edited:
Does anyone know what is causing this issue?
I tried the set_value method as mentioned in other posts, but it didn't work.
Thanks!
Thanks for the vectorized approach, much cleaner! However, I get the following error, and the value is still not updating:


 
     
     
    