Here's my dataset
id keyword
1 transfer atm transfer atm
2 transfer transfer atm
3 atm transfer hospital
Here's what I want is sort keyword alphabetically and make this unique, based on alphabetical the word on keyword
after sort alphabetically is atm
, hospital
, and transfer
id keyword
1 atm transfer
2 atm transfer
3 atm hospital transfer
Try this:
df['keyword']=df['keyword'].apply(lambda x:' '.join(sorted(set(x.split()))))
O/P:
id keyword
0 1 atm transfer
1 2 atm transfer
2 3 atm hospital transfer
Explanation:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With