df['color'] = ['red' if x == 'Z' else 'green' for x in df['Set']]
df.loc[df['column name'] condition, 'new column name'] = 'value if condition is met'
df.loc[df['age1'] - df['age2'] > 0, 'diff'] = df['age1'] - df['age2']
# importing pandas as pd
import pandas as pd
# Creating the dataframe
df = pd.DataFrame({'Date' : ['11/8/2011', '11/9/2011', '11/10/2011',
'11/11/2011', '11/12/2011'],
'Event' : ['Music', 'Poetry', 'Music', 'Music', 'Poetry']})
# Print the dataframe
print(df)