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
Numpy has a function explicitly for this purpose: asscalar
>>> np.asscalar(np.array([24])) 24
This uses item() in the implementation.
item()
I guess asscalar was added to more explicit about what's going on.
asscalar