I have defined the function that takes two arguments and returns two values. It looks like as below:
def normalized_Value(x,RY):
Norm = 0
if RY >= 2016:
if x > 3.382:
x = 3.382 #return 3.382
Norm = 1
else:
x = x
#return x
return x,Norm
else:
if x > 11.93:
x = 11.93 #return 3.382
Norm = 1
else:
x = x
#return x
return x,Norm
I called the function in dataframe to create two new columns in the dataframe. I used following code to call the function:
df['Normalized_val'], temp['Normalized val event'] = zip(*temp[['value','RY']].apply(normalized_Value))
However, when I ran the code it throws an error message of missing argument,
TypeError: normalized_Value() missing 1 required positional argument: 'RY'
I am passing two arguments in the code, not sure why it is throwing an error message. Could anyone help in rectifying the issue?
normalized_Value,normalized_valandnormalized_SAIDI?normalized_Valueto work on two values, you could have it accept a tuple and split it internally. e.g.def normalized_Value(pair): x, RY = pairbecause pandas would just supply your function with a single argument.