I am trying to figure out how a function works np.partition. For example, consider
arr = np.array([ 5, 4, 1, 0, -1, -3, -4, 0])
If I call np.partition(arr, kth=2), I received
np.array([-4, -3, -1, 0, 1, 4, 5, 0])
I expect that after the partition array is divided into elements smaller than one, one and more elements. But the second zero is placed in the last position of the array, which is not the right place after the partition.
source
share