Questions tagged «numpy-slicing»

4
从NumPy数组中选择特定的行和列
我一直在发疯,试图找出我在这里做错了什么愚蠢的事情。 我正在使用NumPy,并且我想从中选择特定的行索引和特定的列索引。这是我的问题的要点: import numpy as np a = np.arange(20).reshape((5,4)) # array([[ 0, 1, 2, 3], # [ 4, 5, 6, 7], # [ 8, 9, 10, 11], # [12, 13, 14, 15], # [16, 17, 18, 19]]) # If I select certain rows, it works print a[[0, 1, 3], :] …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.