I have the following dataframe
text ext_nms ext_dt ext_cd ext_addr
Stonetrust CRR xxx xxx xxx
Wilkes CRR xxx xxx xxx
wcv 0086967 05 xxx xxx COD xxx
SILVER INC xxx xxx xxx ADD
PO BOX 988 xxx xxx xxx ADD
LA 70520 xxx xxx xxx ADD
02/12/2019 xxx DAT xxx ADD
My expected output:
text ext_nms ext_dt ext_cd ext_addr out
Stonetrust CRR xxx xxx xxx CRR
Wilkes CRR xxx xxx xxx CRR
wcv 0086967 05 xxx xxx COD xxx COD
SILVER INC xxx xxx xxx ADD ADD
PO BOX 988 xxx xxx xxx ADD ADD
LA 70520 xxx xxx xxx ADD ADD
02/12/2019 xxx DAT xxx xxx DAT
Essentially, I want to create a new column that has a non-xxx string and that value needs to be moved to that new column.
What I tried:
df['qs_key'] = df.filter(like='^ext').replace('^xxx', '').apply(lambda x: ''.join(x), axis=1)
I am not getting the output that I desire.
Any help will be appreciated. thanks