I have a list L of arrays:
L = ( array1,
array2,
array3,
array4... )
This list is created starting from a Pandas data frame, thus, every single row of the old data frame is now an array inside a list.
Using Euclidean Distance I want to:
- Iterate through all the arrays
- Select only arrays in which the 2nd item is included between
10and100 - Given an array
arr1, select the most similar one (let's sayarr4) - Replace the 2nd item in
arr4with 2nd item inarr1
To visualize it:
Iterate through all the arrays
L = ([87, 30, 45, 99], [11, 21, 31, 41], [560, 47, 85, 328], [167, 32, 98, 379] )Select only arrays in which the 2nd item is included between
10and100L = ([87, 30, 45, 99], [11, 21, 31, 41], [560, 47, 85, 328], [85, 33, 43, 97] )Given an array
arr1, select the most similar one (let's sayarr4)array 1 = ( [87, 30, 45, 99] ) array 4 = ( [85, 32, 43, 97] )Now let's call for simplicity:
P = 30 (array 1, 2nd element)
X = 32 (array 4, 2nd element)
Replace the 2nd item in
arr4(P) insidearr12nd position (X)array 1 = ([87, 32, 45, 99])
Many thank and advance for whatever hint that can be useful!