Suppose I have 1x1x1x1x... array and wish to convert it to scalar?
How do I do it?
squeeze does not help.
squeeze
import numpy as np ma
You can use np.take -
np.take(matrix,0)
Sample run -
In [15]: matrix = np.array([[67]]) In [16]: np.take(matrix,0) Out[16]: 67 In [17]: type(np.take(matrix,0)) Out[17]: numpy.int64