Assume there is a DataFrame such as
import pandas as pd
import numpy as np
df = pd.DataFrame({'A':[21, 11, 31, 45],
'B':[10, 20, 10, 11],
'C':[57, 22, 34, 10]})
A B C
0 21 10 57
1 11 20 22
2 31 10 34
3 45 11 10
I would like to write a function that can be used with lambda such as
def WeightedScore(x, probs):
total = 0
for i in range(len(probs)):
total += x[i]*probs[i]
return total
df ['out'] = df.apply(lambda x: WeightedScore(x['A'], x['B'], x['C'], probs = (0.2, 0.3, 0.5)), axis = 1)
But I got an error something like this
TypeError: WeightedScore() got multiple values for argument 'probs'
Any suggestions? many thanks in advance!