customer_name ANDY
number_of_product_variants 2
number_of_channels 1
number_of_discount_codes 1
order_count 1
order_name #1100,#1100
discount_code Christmas2020, Christmas2020
channel Instagram, Instagram
product_variant Avengers Set A, Avengers Set B
I would like to remove the duplicate word only if the string contains duplicates.
Expected output:
customer_name ANDY
number_of_product_variants 2
number_of_channels 1
number_of_discount_codes 1
order_count 1
order_name #1100
discount_code Christmas2020
channel Instagram
product_variant Avengers Set A, Avengers Set B
The code I tried:
def unique_string(l):
ulist = []
[ulist.append(x) for x in l if x not in ulist]
return ulist
customer_df['channel_2']=customer_df['channel']
customer_df['channel_2'].apply(unique_string)
Using the code below for only the channel
column returns:
0 [S, e, a, r, c, h, ,]
1 [P, a, i, d, , A, s, :, S, o, c, l]
2 [P, a, i, d, , A, s, :, S, o, c, l, ,]
3 [U, n, k, o, w, ,]
```