Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从多维数组中选择除一列之外的所有元素。
我认为它是这样的:blah[:,[1,]]
所以如果数组是:[[1,2,3],[4,5,6]]
我想得到:[[2,3],[5,6]]
In [8]: ar = np.array([[1,2,3], [4,5,6]]) In [9]: ar Out[9]: array([[1, 2, 3], [4, 5, 6]]) In [11]: ar[:, 1:] Out[11]: array([[2, 3], [5, 6]])
我建议你使用这个:
a = [[1,2,3],[4,5,6]] res = [sub[1:] for sub in a]
希望它有效!