+ 1
How to print the index's of numpy.ndarray?
Let's say my numpy.ndarray represented by a=[[[1 2 3 4] [5 6 7 8]]] And I want to print the index values one after the other like For I in range(Len(a)): Print(a[I]) The output should look like this: [1 2 3 4] [5 6 78] How can I do this?
1 Answer
0
youâll notice that the array is of shape 1, 1, 2. So youâll have to go in deeper with the indexing. You are iterating over a when you need to iterate over a[0]. However, the for loop is also stronger than how you are using it:
for entry in a[0]:
print(entry)
PS: an index is a number that refers to a location in an iterable, not something in the iterable itself. Index is the address, the thing in the iterable is the house itself. You were talking about houses like they were addresses.