I am just new in Python, and I am trying to do an analysis. But before that, I want to recode some of the variables. I am wondering if this R code has an equivalent in Python.
df$col1 <- ifelse(df$col1 == "yes", 1, 0)
Here df
is a pandas.DataFrame
and col1
is one of its columns.