I have found different answers to this question but none pulling data from existing column. Let's say I have DataFrame
purchase=
{'date':['11/03/2021','12/03/2021','14/03/2021','11/03/2021'],
'price':[300, 400,200, 200],
'currency':['eur', 'usd','usd','usd'],
'qty':[200, 300, 400, 500],
'salesmanA':['Jack', 'x', "Mike", 'x'],
'salesmanB':['x', 'John', "x", 'David']}
df=pd.DataFrame(purchase)
I want to set a new column df['salessup'] which should be equal to SalesmanA if its value is not 'x', and if it's x to salesmanB new columns should be like ['salessup']=['Jack','John','Mike','David'] thank you in advance.