I have a text column with chat information, I want to pass in a list of words that if they appear in that text column will ammend the error column to 1 and 0 if the words do not appear:
chatid text card_declined booking_error website_error
401 hi my card declined.. 0 0 0
402 you website crashed.. 0 0 0
403 hi my card declined.. 0 0 0
for example
carddeclined = ['card declined', 'Card error']
for i in df[df['textchat'].str.contains('|'.join(carddeclined),na=False)]:
df['card declined'] = 1
This currently just returns all card declined rows with 1