0

I have a program to look through rows, and reformat/replace incorrect sizes.

For instance:

Option2 Value Shirt Color Actual Size
L Yellow XL
XL Black 2XL
2XL Green 3XL

So I'm using some code to go through the dataframe from a CSV and replace the documented size with the actual size.

for index, row in df.iterrows():
   if df.loc[index, 'Documented Size''] == 'L':
       df['Documented Size'].replace(to_replace=['L'], value='XL', inplace=True)
   elif df.loc[index, 'Documented Size''] == 'XL':
       df['Documented Size'].replace(to_replace=['XL'], value='2XL', inplace=True)

However, it just seems to replace ALL entries of 'Documented Size' with the first 'if,' like so:

Option2 Value Shirt Color Actual Size
XL Yellow XL
XL Black 2XL
XL Green 3XL

0 Answers0