I am creating a new column with "if, elif, else" based on another column.
My syntax is generating only the value listed in my "if" statement, however it should be returning "elif" and "else" for some values in the other column.
The variable I am creating is OHX02N, based on OHX02CTC, and I am getting 3 for all, which is the command in my first if statement, even though it should be returning 3,1,1,3,1 for the first five obs.
Thoughts?
def F (value):
if FINALSET.loc[value,'OHX02CTC'] == 'E' or 'P' or 'R':
FINALSET.loc[value, 'OHX02N'] = 3
elif FINALSET.loc[value,'OHXO2CTC'] == 'J' or 'T':
FINALSET.loc[value,'OHX02N'] = 2
elif FINALSET.loc[value,'OHX02CTC'] == 'K' or 'Z':
FINALSET.loc[value,'OHX02N'] = 1
else:
FINALSET.loc[value,'OHXO2N'] = 0
for value in range(len(FINALSET)):
F(value)