Reputation: 494
I have a function which takes the list as an input. The list is as follows :
[ [ [179.0,77.0], [186.0,93.0], [165.0,91.0 ],..],
[ [178.0,76.0 ],[185.0,93.0 ],[164.0,91.0 ] ,..],...]
I want to give this list by index so that the function will normalize(already written) the data for each index and predict(already written the function logic) for each index. The example is as follows :
normalzed_list = normalize(list)
predict(normalized_list) # this function should predict based on the index of the list.
I would appreciate any help. Thank you.
Upvotes: 0
Views: 59
Reputation: 640
I would use map()
normalized = map(normalize, lst)
predicted = map(predict, normalized)
result = list(predicted) # evaluate the generator
For debugging purposes you would want to put list()
around the first map()
.
Edit:
The index you can get by enumerate()
.
predicted = map(lambda e: predict(e[0], e[1]), enumerate(normalized))
e[0] has the index, e[1] the normalized list.
Upvotes: 1
Reputation: 23
If you already know the index of the list element, can simply do this
normalized_list = normalize(list[idx])
. Where idx is the known index.
Upvotes: 1