I have DataFrame like below:
data = pd.DataFrame({"col1" : ["a", "b", "c"],
"binary" : [0, 1, 0]})
I would like to create and add new column in this DataFrame
called "new"
where if in column "binary"
is 1 then I want to have data from "col1"
in my created column "new"
, but if in "binary"
column is 0 then I want to have np.NaN
. Below is the result which I really need based on my description and DatFrame above.