I have such a data frame:
#v1 v2 v3 v4 v5
a b b c 1 1 2 2 2 3 3 3 3 4 4 4 4 4 4 ...
....
As you see, the v5 column contains word id. And I have a list of word id to remove:
toRve = ['1','3','5'.....]
And I write a for loop to remove the word id in list:
for i in toRve:
df[v5] = df[v5].str.replace("{0} ".format(i), "")
But I got this result:
#v1 v2 v3 v4 v5
a b b c 222444444 ...
....
As the 22 23has been regarded 2+2+23 so it has been changed to 223. Do you have any good idea to solve this problem? Thank you in advance!
Why all the space has gone? Could you help me? Thank you in advance!
22will change to2either. I want exactlyi(2) to be removed.