Is it possible to import module within a python lambda function? For example, i have a lambda function which requires to import math
import math
is_na_yes_no = lambda x: 'Yes' if math.isnan(x) else 'No'
How can I include the import math
statement within the lambda function?
To clarify, I have a scenario that need to put some lambda functions in a config file and evaluate the function in some other python files, exmample:
{
"is_na_yes_no" = "lambda x: 'Yes' if math.isnan(x) else 'No'"
}
In this case, the python file that evaluating those lambda functions need to all modules required.