what is the procedure to remove a word from a string in one column column that occurs in the other column?
eg:
Sr A B C
1 jack jack and jill and jill
2 run you should run, you should ,
3 fly you shouldnt fly,there you shouldnt ,there
It can be seen that I want column C
, such that it is B minus contents of A. Please note the 3rd example, where fly
is followed by a comma , so it should also take into consideration the punctuations (if the code is more towards detecting a space around it).
Column A
can also have 2 words , so these need to be removed.
I need an expression in Pandas, something like:
df.apply(lambda x: x["C"].replace(r"\b"+x["A"]+r"\b", "").strip(), axis=1)