how does searchsort in python work?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: To make my question clear say if I have an array a as Out[123]: [1, 3, 4, 6, 9, 10, 54] When I try to search the numbers in the list, searchsort returns correct value but when I try something not in the list, it returns an absurd value here is some of the results In [131]: a Out[131]: [1, 3, 4, 6, 9, 10, 54] In [132]: searchsorted(a,1) Out[132]: 0 In [133]: searchsorted(a,6) Out[133]: 3 In [134]: searchsorted(a,[9,54,1]) Out[134]: array([4, 6, 0]) In [135]: searchsorted(a,[9,54,1,0]) Out[135]: array([4, 6, 0, 0]) ***> # here 0 is not in the