i want a solution where i have to check if values of a dataframe column has specific code and if it is so i will add a predefined prefix to it. to make it easier please look into the folowing example. For say i have a Dataframe like below.
PRODUCT_KEY
EXI-CD_5S-WW5678
EX-PWN-PRO-193
EX-NIS-NS-HZ049
EX-NCI-DSI-A-R
EX-GCA-FAC-F
AU-345654
NL-108793
HK-678903
WW-564312
DE-123243
So for this column what i want to do is ; i want to check if it starts with 'AU' or 'NL' or 'HK' or 'ww' or 'DE' and if so then i will add a prefix 'GST-YIP' and for rest it will be same. the resultant dataframe will look like below.
PRODUCT_KEY
EXI-CD_5S-WW5678
EX-PWN-PRO-193
EX-NIS-NS-HZ049
EX-NCI-DSI-A-R
EX-GCA-FAC-F
GST-YIP-AU-345654
GST-YIP-NL-108793
GST-YIP-HK-678903
GST-YIP-WW-564312
GST-YIP-DE-123243
i am trying to do it within a for loop.
for i in df['PRODUCT_KEY']:
if i.str.contains('AU'|'HK'|'WW'|'DE'):
df['PRODUCT_KEY] = 'INC-AAB' + i
else:
f['PRODUCT_KEY] = i
But this is not giving me correct result.