select closest values from two different arrays
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 Select Closest Values From Two Different Arrays
00:37 Accepted Answer Score 7
00:44 Thank you
--
Full question
https://stackoverflow.com/questions/1871...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 Select Closest Values From Two Different Arrays
00:37 Accepted Answer Score 7
00:44 Thank you
--
Full question
https://stackoverflow.com/questions/1871...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy
#avk47
ACCEPTED ANSWER
Score 7
>>> K = abs(A - C) < abs(B - C) # create array of bool
[[True, False, False],
[True, True, False],
[False, False, False]]
>>> D = where(K, A, B) # get elements of A and B respectively