📜  熊猫 if python 代码示例

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

代码示例6
import pandas as pd

names = {'First_name': ['Jon','Bill','Maria','Emma']}
df = pd.DataFrame(names,columns=['First_name'])

df.loc[df['First_name'] == 'Bill', 'name_match'] = 'Match'  
df.loc[df['First_name'] != 'Bill', 'name_match'] = 'Mismatch'  
 
print (df)