in my program I want to have 1D array, convert it to a 2D array, convert it back to a 1D array again and I want to search for a value in the final array. In order to change 1D array to 2D, I used numpy. I used where() function in order to search through the array and in the end I get this output:
(array([4], dtype=int32),)
I get this result but I only need its index, 4 in case. Is there a way which I can only get the numerical result of the where() function or is there an alternative way which allows me to do 1D to 2D and 2D to 1D conversions without using numpy?
import numpy as np
a = [1,2,3,4,5,6,7,8,9];
print(a)
b = np.reshape(a,(3,3))
print(b)
c = b.ravel()
print(c)
d = np.where(c==5)
print(d)