In [139]: a=np.array([[0, 1, 2],
...: [0, 2, 3],
...: [0, 1, 3],
...: [1, 2, 3]])
In [140]: b=np.array([[255, 255, 255],
...: [255, 0, 0],
...: [ 0, 255, 0],
...: [ 0, 0, 255]])
To make a structured array that display like this, use:
In [141]: face = np.zeros(a.shape[0], dtype=[('a',int,3), ('b1',int),('b2',int),('b3',int)])
In [142]: face
Out[142]:
array([([0, 0, 0], 0, 0, 0), ([0, 0, 0], 0, 0, 0), ([0, 0, 0], 0, 0, 0),
([0, 0, 0], 0, 0, 0)],
dtype=[('a', '<i8', (3,)), ('b1', '<i8'), ('b2', '<i8'), ('b3', '<i8')])
In [143]: face['a']=a
The other values have to be set with a list of tuples:
In [145]: face[['b1','b2','b3']] = [tuple(row) for row in b]
In [146]: face
Out[146]:
array([([0, 1, 2], 255, 255, 255), ([0, 2, 3], 255, 0, 0),
([0, 1, 3], 0, 255, 0), ([1, 2, 3], 0, 0, 255)],
dtype=[('a', '<i8', (3,)), ('b1', '<i8'), ('b2', '<i8'), ('b3', '<i8')])
In [147]: print(face)
[([0, 1, 2], 255, 255, 255) ([0, 2, 3], 255, 0, 0)
([0, 1, 3], 0, 255, 0) ([1, 2, 3], 0, 0, 255)]
Or to make an object dtype array:
In [148]: res = np.zeros((4,4), object)
In [151]: res[:,0] = a.tolist()
In [152]: res
Out[152]:
array([[list([0, 1, 2]), 0, 0, 0],
[list([0, 2, 3]), 0, 0, 0],
[list([0, 1, 3]), 0, 0, 0],
[list([1, 2, 3]), 0, 0, 0]], dtype=object)
In [153]: res[:,1:] = b
In [154]: res
Out[154]:
array([[list([0, 1, 2]), 255, 255, 255],
[list([0, 2, 3]), 255, 0, 0],
[list([0, 1, 3]), 0, 255, 0],
[list([1, 2, 3]), 0, 0, 255]], dtype=object)