How do I create a new column where the values are selected based on an existing column?

How do I add a color column to the following dataframe so that color='green' if Set == 'Z', and color='red' otherwise?

   Type  Set
1     A    Z
2     B    Z           
3     B    X
4     C    Y

← Назад к списку