I have 2 sets of data, Y and X. Y data is a single column and X contains multiple columns. X & Y have different lengths. Each row in X (columns C-L) is a sample on its on. In other words, all the variables in each row of X (columns C-L) belongs to one sample. As you can see in the attached file, there are 12 Y data and hence I want to extract the corresponding X data (12 of them) that will match well with Y. So I want to take the first value in Y, perform some sort of matching analysis all rows of X to see which one give the least error of matching or some sort of distance. After A value in X has been found that matches well with the first value in Y, either by distance or by some other methods, I want that X row to be replaced with NaN so that it wont be selected again. The procedure will be repeated on all the remaining Y values. I also want the indices or row number of the each of the selected X data to that of the Y so that I can extract them latter. Any suggestions?