I have a 2D numpy array with elements of the type np.void
that are essentially tuples. Is there an efficient way to unpack the values in these tuples to a 3rd dime
You can view as a standard numpy
array to allow for the indexing you're after.
b = a.view('(3,)
array([[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]],
[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]],
[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]], dtype=uint16)
>>> b.shape
(3, 3, 3)
>>> b[:, :, 0]
array([[1, 1, 1],
[1, 1, 1],
[1, 1, 1]], dtype=uint16)