on-internet
← Community

"ValueError: setting an array element with a sequence" when assigning the result of np.where

Stack Overflow ·

When I execute this Python code, I get an error message: ValueError: setting an array element with a sequence a = np.array([1,3,5,7,9], dtype=int) c = np.array([3,4,7,8,9], dtype=int) b = np.zeros(len(a)) for i in range(len(a)): b[i] = np.where(a == int(c[i])) What's the problem? The whole error: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-606-7b50beb044f5> in <module>() 14 15 for i in range(len(a)): ---> 16 b[i]= np.where(a == int(c[i])) ValueError: setting an array element with a sequence.

Comments

Sign in or sign up to comment and upvote.

No comments yet.