I would like to add a new column called XXX based on the last letter in the "indicator" column if:
indicator ends with an S -> Use the value from 'Vendor 5 Ask Price XXX'
indicator ends with an B -> Use the value from 'Vendor 5 Bid Price XXX'
so the new column would be : XXX : [100,nan,107,103]
df = {'indicator': ['45346B','24536S','34636S','657363B'],
'Vendor 5 Bid Price XXX' : [100,None,102,103],
'Vendor 5 Ask Price XXX' : [105,None,107,108]}
pd.DataFrame(df)
indicator Vendor 5 Bid Price XXX Vendor 5 Ask Price XXX
0 45346B 100.0 105.0
1 24536S NaN NaN
2 34636S 102.0 107.0
3 657363B 103.0 108.0