For apply functions, they pass in the arguments as a series or numpy array. So in general you can modify your function to assume the arguments come in as a list:
# Fake data
name = ['MoneyCard','Goldcard','UK_Card','Simplecard']*2
succ = [True]*4 + [False]*4
df = pd.DataFrame(zip(name,succ),columns=['name','succ'])
# dictionary for success/fail
di_map = {'MoneyCard': [5,2],
'Goldcard': [10,5],
'UK_Card': [3,1],
'Simplecard': [1,0.5]}
# assumes first is name, second is success
def fees(arg):
if arg[1]:
return di_map[arg[0]][0]
else:
return di_map[arg[0]][1]
# make sure to pass in correct order
df[['name','succ']].apply(fees,axis=1)
There are ultimately many different ways you might do this. You could use merge or replace functions as well. apply
is nice as it is more general and can be modified how you want to deal with say missing values or cards not in your list.
Here is another example using dictionaries + replace to accomplish the same end result:
# Another approach
dip = {c:v[1] for c,v in di_map.items()}
din = {c:v[0] for c,v in di_map.items()}
df['fee'] = df['name'].replace(dip)
nfee = df['name'].replace(din)
df['fee'].where(df['succ'], nfee, inplace=True)