Little modification to This Answer of acharuva
df['color'] = df.apply( lambda x: 'red' if x == 'Z' else 'green', axis=1)