After certain string is found mark every after string as true,pandas

Question:

s = pd.Series({0: 'registration address-complement-insert-confirmation input',
 1: 'decision-tree first-interaction-validation options',
 2: 'decision-tree invalid-format-validation options',
 3: 'decision-tree first-interaction-validation options',
 4: 'registration address-complement-request view',
 5: 'onboarding return-start origin',
 6: 'registration address-complement-request origin',
 7: 'decision-tree identified-regex options',
 8: 'decision-tree first-interaction-validation options',
 9: 'decision-tree first-interaction-validation options'})

I have the following series object. What I want to do is to map it and mark every single string after ‘onboarding return-start origin’ as true. Any ideas on how I could build this condition?

Wanted result

s = pd.Series({0: False,
 1: False,
 2: False,
 3: False,
 4: False,
 5: True,
 6: True,
 7: True,
 8: True,
 9: True})
Asked By: INGl0R1AM0R1

||

Answers:

Use Series.cummax with test first matched value by Series.eq:

s = s.eq('onboarding return-start origin').cummax()
print (s)
0    False
1    False
2    False
3    False
4    False
5     True
6     True
7     True
8     True
9     True
dtype: bool
Answered By: jezrael
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.