New to python. I am trying to figure out the best way to create a column based on other columns. Ideally, the code would be as such.
df['new'] = np.where(df['Country'] == 'CA', df['x'], df['y'])
I do not think this works because it thinks that I am calling the entire column. I tried to do the same thing with apply but was having trouble with syntax.
df['my_col'] = df.apply(
    lambda row: 
    if row.country == 'CA':
        row.my_col == row.x
        else:
            row.my_col == row.y
I feel like there must be an easier way.
 
     
    