Buat Pernyataan Kondisi di Panda Kolom
df['color'] = ['red' if x == 'Z' else 'green' for x in df['Set']]
Fragile Finch
df['color'] = ['red' if x == 'Z' else 'green' for x in df['Set']]
import pandas as pd
import numpy as np
df = pd.DataFrame({'Type':list('ABBC'), 'Set':list('ZZXY')})
df['color'] = np.where(df['Set']=='Z', 'green', 'red')
print(df)