I am using set in a dataframe to remove duplicate words in a list, but the original words changed in the result.
these are the words shown in dataframe:
[Which, one, dissolve, in, water, quickly, sugar, ,, salt, ,, methane, and, carbon, di, oxide, ?]
note: words like 'sugar,' and 'salt,' are with comma
these are the result shown in dataframe after using set: {oxide, sugar, Which, di, water, in, ,, salt, carbon, dissolve, one, ?, methane, quickly, and}
data['sent1']=data['sent1'].apply(lambda x : set(x))
I want the words to keep the same order after using set. I really get puzzled why set will change the original words(form'sugar,'to'sugar')