Uncategorized

multiple logic on a single column of pandas dataframe in python


INPUT column value can be A or B or C

REQUIRED OUTPUT value based on condition as follows

condition(1)if INPUT value A then REQUIRED OUTPUT A

condition(2)if INPUT value C then REQUIRED OUTPUT C

condition(3.i)if INPUT value B and B present after C then REQUIRED OUTPUT C

condition(3.ii.a)if INPUT value B and B present after A and upto 3 times B then REQUIRED OUTPUT A

condition(3.ii.b)if INPUT value B and B present after A and after 3 times B then REQUIRED OUTPUT C

enter image description here



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *