I originally asked the question in the following link which was answered well. Please just review for reference sake:
Assume I have the follwing output:
import pandas as pd
df = pd.DataFrame()
df['A'] = ('0','0','0','0','0','0','YES','0','YES','YES','YES','0','0','0','0','YES','0','0','0','0','0','0','0','0', 'NO','0','0','0','0')
df['B'] = ('1','','','3','2','1','','','','','','','','','','','','','','','','','','', '8','','','','')
df['C'] = ('','','','','','','9','','','','','','','','','9','8','7','6','5','4','3','2','1', '','','','','')
print(df)
I have a follow up problem whereby I wish the following:
if a NO on column (col) A occurs with either an 8 or 9 on col B than col D also is NO. Only f it is followed by a 1 on col C then col D is BAD. BAD is continued up to 9 or if no greater number occurs on col C
if a YES on column (col) A occurs with either an 8 or 9 on col C than col D also is YES. Only if it is followed by a 1 on col B then col D is GOOD. GOOD is continued up to 9 or if no greater number occurs on col B
I might be missing a rule or 2 but if you can make the dataframe look like following I think it is on the right track
Basically I am aiming for the output to look as follows:
df['D'] = ('','','','GOOD','GOOD','GOOD','YES','','','','','','','','','YES','BAD','BAD','BAD','BAD','BAD','BAD','BAD','BAD', 'NO','','','','')
print(df)