Adding a custom column to a RDataFrame

Hi, I would like to create a new column basing on the value of another variable in the dataframe for each entry.
What I would like to do is to have a column called “C_origin” which is filled for every entry with 1 if TrackOrigin is equal to 2, and with 0 for all the other TrackOrigin values.
What I tried to do is: dataframe.Define(“C_origin”, “1” if ‘TrackOrigin’==2 else “0”) but this doesn’t seem to work.
I’m currently using python.
Cheers, Michele

dataframe.Define("C_origin", "TrackOrigin==2 ? 1 : 0")

might work?

1 Like

Thanks really much, it worked!