【发布时间】:2021-08-16 21:02:41
【问题描述】:
数据集:
cust no acc no schme code product code
0 102283447 809002316863 swmse rbl finserve
1 102283447 809002661291 ecltl ecl
2 101124069 809001215907 aksme akshada
3 101124069 809001211305 aksme akshada
4 101124069 8090012837146 ecltl ecl
import pandas as pd
import numpy as np
if ((data['cust no'].duplicated()==True).any() and (data['product code']!='rbl finserve').any()):
data['new']=='other bc acc'
else:
data['new']==data['schme code']
data['new']=np.nan
for i in data['product code']:
if i!='rbl finserve':
if (data['schme code']=='ecltl').any():
data['new']=='other ecl bc'
else:
data['new']=data['schme code']
如果帐户超过两个,我想更改 schme 代码。对于那些将第一个帐户产品作为 rbl finserve 的帐户,则不要更改,但如果不是“rbl finserve”,则将 schme 代码从“ecltl”更改为“其他 ecltl bc”
【问题讨论】:
标签: dataframe replace conditional-statements