I have been breaking my head with this function.
def snatch(data,threshold):
Given I have the following data:
data = { 'x': [1, 2, 3, 7], 'y': [1, 3, 7, 2] }
threshold = { 'x': 3, 'y': 2 }
Briefly, the data dictionaries' values are supposed to merge as one list, if they are above or equal to the threshold's values.
i.e. [3,7,7,3,2]
for 'x' 3,7 are above or equal to threshold 'x'. And for 'y' 3,7,2 are above or equal to threshold 'y.' The mean is hence computed.
The second condition concerns the absence of a threshold. In that case, the respective letter key is excluded from the list and thus the product mean.
e.g. thresh = { 'x': 3 }
hence the list from data is only [3,7]