I am trying to learn Python after learning R and an simple ifelse statement.
In R I have:
df$X <- if(df$A == "-1"){-df$X}else{df$X}
But I am unsure how to implement it in Python, I have tried:
df['X'][df['A'] <1] = -[df['X']
df['X'][df['A'] >1] = [df['X']
But this leads to errors, would appreciate some help.
Aucun commentaire:
Enregistrer un commentaire