I would like to take the two smallest values from an array x. But when I use np.where:
A,B = np.where(x == x.min())[0:1]
I get this error:
ValueError: need more than 1 value to unpack
How can I fix this error? And do I need to arange numbers in ascending order in array?
[0:1]slicing syntax is equal to[:1]syntax, which means take the first element from that array. Why don't you do something likeA, B = [np.where(x==x.min())] * 2(unpacking a list)? You really don't need the slicing syntax, as there's only one minimal value in a given sequence.[ 0.0619444 0.01415524 0.0644649 0.00348524 0.01608257 0.03753657 0.0392854 0.0503084 0.10295524]0.00348524and0.01415524forAandBrespectivly?