The following code creates as column called ‘Flagged’ in SAS:
Case When t3.Proportion=. then case when t3.'Standardised proportion'n >t1.SigmaMultiple Then 1 else 0
End
Else
Case When t3.Proportion=. and abs(t3.'Standardised proportion'n) > t1.SigmaMultiple Then 1 Else 0
End
End
I'm trying to replicate it in python and usually I would have done a conditions code however the nested Case when aspect is confusing me.
The code i tried but didn't seem to be matching:
conditions =[
((dfSigmamissing['Proportion'] == 0) & (dfSigmamissing['SP'] > dfSigmamissing['SigmaMultiple'])),
((dfSigmamissing['Proportion'] == 0) & (dfSigmamissing['SP'] < dfSigmamissing['SigmaMultiple'])),
((dfSigmamissing['SP'].abs() > (dfSigmamissing['SigmaMultiple'])))
]
choices = [1,0,1]
dfSigmamissing['Flagged'] = np.select(conditions, choices, default=0)
Any help would be greatly appreciated.
Thank you
Aucun commentaire:
Enregistrer un commentaire