Issue
This is what I want to do:
a = [[1, 2],[3,4]]
b = np.zeros(shape = (2,2))
b[:, 1:] = a[:,1:]
But I get this error message:
TypeError: list indices must be integers or slices, not tuple
Solution
As @MattDMo has mentioned, you are trying to use numpy slicing on a 2D list. You can fix this by simply converting the list to a numpy array
a = np.array([[1, 2],[3,4]])
b = np.zeros(shape = (2,2))
b[:, 1:] = a[:,1:]
Answered By - phoney_badger
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.