Nov-15-2016, 04:57 PM
Hello,
This isn't necessarily a homework problem or even about a class that I'm taking. I'm trying to teach myself python for graduate level work and I'm using a book to try and teach myself. I came across code in the book and I'm a little confused about. The code is as follows:
Thanks.
This isn't necessarily a homework problem or even about a class that I'm taking. I'm trying to teach myself python for graduate level work and I'm using a book to try and teach myself. I came across code in the book and I'm a little confused about. The code is as follows:
import Numpy as N a = N.reshape(N.arange(8), (2,2,2) ) condition = N.logical_and(a>3, a<6) answer_indices = N.where(condition) answer = (a*2)[answer_indices]Now, what I'm confused about is when you print answer_indices it comes out as:
Output:(array([1, 1]), array([0, 0]), array([0,1]))
and I'm not entirely sure why that is. I may be a little confused with 3-D arrays in general so could somebody explain to me why this comes out this way?Thanks.