I have this code:
pattern = " LLC | CO | CORP | DIV "
col = pd.Series(' TEST LLC TEST CO TEST CORP TEST DIV ')
col = col.map(lambda x:re.sub(pattern, ' ', x))
col
which correctly gives: TEST TEST TEST TEST
However, when I replace the 2nd row with:
col = pd.Series(' COMPUTING DEVICES CO DIV CLDC ')
I get incorrect output: COMPUTING DEVICES DIV CLDC
So in the first example, DIV was correctly removed. However in the second example DIV was not removed even though the code is identical?
Any idea why? and how to fix it? Many thanks in advance!