I am performing some simulations in python that generates 1000 results. Each result has multiple properties such as risk, cost etc
I now want to identify results that meeting certain criteria, for example:
Factor 1, cost should be between 10 and 20
Factor 2, risk should be between 0 and 5
Factor 3...
Factor 4...
....
Currently I am using a series of nested if statements to do this. As more factors are added the nesting gets messy. Is there an elegant alternative for filtering given certain criteria?
There are a lot of solutions that depend on your data and preferred code style. E.g.:
Or just:
Or: