0

The below works

df['notes'] = df['notes'].apply(lambda x: x if 'Issue:' in x else "NO_ISSUE")

however I wanted to ask if I can do this:

df['notes'] = df['notes'].apply(lambda x: x if 'Issue:' or "Root Cause:" in x else "NO_ISSUE")
3awny
  • 223
  • 1
  • 2
  • 7
  • 3
    The problem isn't `or` in a lambda but that `'Issue:' or "Root Cause:" in x ` doesn't mean what you think it means. – John Coleman Oct 10 '21 at 00:38

1 Answers1

1

You can do it

df['notes'] = df['notes'].apply(lambda x: x if ('Issue:' in x or "Root Cause:" in x) else "NO_ISSUE")
BENY
  • 296,997
  • 19
  • 147
  • 204