Topic: in multidimentional numpy-files
All greetings! A question amateurish, do not kick strongly. At first a simple example. Here there is at me a two-dimensional array, for example A = np.array ([[1, 2, 3], [4, 5, 6]]) and is an one-dimensional array of indexes of elements in lines, we tell B = np.array ([2, 0]) I want to receive the one-dimensional array consisting of elements with these indexes in appropriate lines, i.e. [3, 4] In this two-dimensional case I can write a C = A [np.arange (2), B] and to receive that is required. And now the task hardly becomes complicated... Now A is a 3-dimensional array, say, 3x3x100, B - a 2-dimensional array of indexes 3x3. And I want to receive on an output a 2-dimensional array of a C, 3x3, with elements A in which specifies B. I.e. I need to make the such: for i in range (3): for j in range (3): the C [i, j] = A [i, j, B [i, j]] Is a method to make it more elegantly and faster?