Im stuck. im tryin to code this excel formula in a code of python but after searchin and tryin diff codes i cant get the solution.
= IF(AND(K2="inscrito_registro")*OR(L2<>"inscrito_registro")*OR($L2<>"no_necesario")*OR($L2<>""),"con carga","sin carga")
I tried with this code in python but its not correct:
df['Carga']=np.where(df['Registration Status'] == "inscrito_registro" and np.where(df['Estado Cancelacion Cargas'] != "inscrito_registro","con carga","sin carga"))
i just tried this code avodin to try the "or" and its not correct. Any suggestion?
Thnx
CodePudding user response:
try as follows, you don't need a second np.where within the first one
df['Carga']=np.where(
(df['Registration Status'] == "inscrito_registro") &
(df['Estado Cancelacion Cargas'] != "inscrito_registro"),
"con carga",
"sin carga")
use | for the OR condition, and you might need to put the OR conditions in parenthesis
df['Carga']=np.where(
(df['Registration Status'] == "inscrito_registro") &
((df['Estado Cancelacion Cargas'] != "inscrito_registro") |
(df['Estado Cancelacion Cargas'] != "no_necesario") |
(df['Estado Cancelacion Cargas'] != "")
),
"con carga", "sin carga")