为了明确我的问题,如果我有一个数组 a 作为 Out[123]: [1, 3, 4, 6, 9, 10, 54] 当我尝试搜索列表中的数字时,searchsort 返回正确的值但是当我尝试了不在列表中的东西,它返回一个荒谬的值
这是一些结果
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 list, but turns up @ position 0***
In [136]: searchsorted(a,740)
Out[136]: 7
***> # here 0 is not in the list, but turns up @ position 7***
为什么会这样?