📜  Pandas 条件列 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.527000             🧑  作者: Mango

代码示例2
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)