Hi,
I did try to convert the user defined business rule (excel) to an IF condition statement and trying to assign the entire If elif statements to an function. So that I can pass it to below statement to apply the rules.
ouput_df['der_factor'] = input_df.apply(result_func, axis = 1)
When I have the function with manually coding the rules it works (as shown below), I need help on couple of things,
1. Is IF statement the efficient way to handle this scenario?
2. If so, how can I pass the entire dynamically generated IF statement (including elif and returns) in the function.
def result_func(input_df):
if (input_df['ABC'] == 12):
return '1.25'
elif (ip_df['ABC'] == 11):
return '0.25'
else:
return '1'
Any pointers/suggestions would be much helpful.
Thanks.
I did try to convert the user defined business rule (excel) to an IF condition statement and trying to assign the entire If elif statements to an function. So that I can pass it to below statement to apply the rules.
ouput_df['der_factor'] = input_df.apply(result_func, axis = 1)
When I have the function with manually coding the rules it works (as shown below), I need help on couple of things,
1. Is IF statement the efficient way to handle this scenario?
2. If so, how can I pass the entire dynamically generated IF statement (including elif and returns) in the function.
def result_func(input_df):
if (input_df['ABC'] == 12):
return '1.25'
elif (ip_df['ABC'] == 11):
return '0.25'
else:
return '1'
Any pointers/suggestions would be much helpful.
Thanks.