Im trying to convert some old SAS Code to python. I have a conditional statement embbeded in my data step for SAS and want to do a similar thing but in python. SAS Code Below (variable names and values are generic names)
DATA DF1;
SET DF;
IF (A = '1' AND B ^= '2') OR (A='3' AND C ^= '4');
IF D ('5','6','7') AND E >= 8 THEN DELETE;
run;
Python Code as far as I got.
indexNames= DF[((DF['A'] !='1')
& (DF['B']== '2'))
| ((DF['A'] !='3')
& (DF['C']== '4'))].index
DF.drop(indexNames , inplace =True)
indexNames=DF[(DF['F'] == '1')
| (DF['F'] == '2')
|(DF['F] =='3')
& (DF['G'] >= 4)].index
DF.drop(indexNames , inplace = True)
Im not sure this is correct or optimized if anyone has suggestions. I would appreciate it!