用途
np.where:
df['New_State_Name'] = np.where(df['Name']=='Person1',df['State'].map(state_map),df['State'].map(state_map2))
输出:
Name State Year New_State_Name0 Person1 CT 2017 Connecticut1 Person2 FL 2017 BBC-Florida2 Person3 TX 2017 CDA-TX3 Person1 TX 2016 Texas
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)