I have a dataset (with multiple columns but for the sake of sample data, I have added two relevant columns)
Type SKU Sizes
Variable 3 XS,XS
Variation 65 XS
Variation 7 S,M,L
variable 89 S
Variation 90 M
Variation 92 L
I have a list of values stored in dup_arr. I want to remove all sizes after ',' with the SKU values stored in dup_arr. For Example, if dup_arr = 3, I want the end result to look like
Type SKU Sizes
Variable 3 XS
Variation 65 XS
Variation 7 S,M,L
variable 89 S
Variation 90 M
Variation 92 L
Note that the first row doesn't have XS after ','
I am trying to loop through each value and check for values
for i in OF['SKU']:
for j in dup_arr:
if i == j:
OF.loc[OF['Attribute 1 value(s)'] = OF['Attribute 1 value(s)'].str.split(',').str[0]
however, it is removing all the sizes after ',' for all the values of SKU. I can understand why is happening but not sure how to remove all the sizes after ',' for that particular SKU value stored in dup_arr.