Let's say I have the following array:
arr = np.array([[1,2], [3,4]], dtype='u1')
and I want to convert it into a structured array like this one:
strarr = np.array([(1,2), (3,4)], dtype=[('a', 'u1'), ('b', 'u1')])
If I just try
arr.astype([('a', 'u1'), ('b', 'u1')])
it returns
>>> array([[(1, 1), (2, 2)],
[(3, 3), (4, 4)]], dtype=[('a', 'u1'), ('b', 'u1')])
How can I convert the array so that it uses all elements of a row to fill the fields (provided that the numbers match) instead of duplicating each element?