I have a dataframe which looks like as below
df = pd.DataFrame({'A': [0, 1, 2, 3, 4],
'B': ['a is host 0itdsiekivnme0itdxm', 'mmm pc is host sesoltsm09sds', 'winter on is host sesdfdfdf9', 'd is host SESCPIWM1344 sdfds asd', 'check my host sesdfdsm1dsdd0 friendly']})
I am trying to find the word after 'host' and replace the first two character with xx
like below
df = pd.DataFrame({'A': [0, 1, 2, 3, 4],
'B': ['a is host xxtdsiekivnme0itdxm', 'mmm pc is host xxsoltsm09sds', 'winter on is host xxsdfdfdf9', 'd is host xxSCPIWM1344 sdfds asd', 'check my host xxsdfdsm1dsdd0 friendly']})
I tried following, but it doesn't work
df['spc3'] = df['B'].str.replace('(?<=host)(\w{2})', r'\1xx')