Это может быть сделано либо путем понимания списка, либо, если результат должен быть массивом с np.frompyfunc
:
# create example
>>> data = np.array([np.arange(n*12).reshape(n, 2, 6) for n in range(2, 5)])
>>> features = np.array([np.ones((n, 2, 6), int) for n in range(2, 5)])
>>> data.shape, features.shape
((3,), (3,))
>>>
# list comprehension
>>> [np.concatenate(xy, 2) for xy in zip(data, features)]
[array([[[ 0, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],
[ 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1]],
[[12, 13, 14, 15, 16, 17, 1, 1, 1, 1, 1, 1],
[18, 19, 20, 21, 22, 23, 1, 1, 1, 1, 1, 1]]]), array([[[ 0, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],
[ 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1]],
[[12, 13, 14, 15, 16, 17, 1, 1, 1, 1, 1, 1],
[18, 19, 20, 21, 22, 23, 1, 1, 1, 1, 1, 1]],
[[24, 25, 26, 27, 28, 29, 1, 1, 1, 1, 1, 1],
[30, 31, 32, 33, 34, 35, 1, 1, 1, 1, 1, 1]]]), array([[[ 0, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],
[ 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1]],
[[12, 13, 14, 15, 16, 17, 1, 1, 1, 1, 1, 1],
[18, 19, 20, 21, 22, 23, 1, 1, 1, 1, 1, 1]],
[[24, 25, 26, 27, 28, 29, 1, 1, 1, 1, 1, 1],
[30, 31, 32, 33, 34, 35, 1, 1, 1, 1, 1, 1]],
[[36, 37, 38, 39, 40, 41, 1, 1, 1, 1, 1, 1],
[42, 43, 44, 45, 46, 47, 1, 1, 1, 1, 1, 1]]])]
# frompyfunc
>>> np.frompyfunc(lambda *xy: np.concatenate(xy, 2), 2, 1)(data, features)
array([array([[[ 0, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],
[ 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1]],
[[12, 13, 14, 15, 16, 17, 1, 1, 1, 1, 1, 1],
[18, 19, 20, 21, 22, 23, 1, 1, 1, 1, 1, 1]]]),
array([[[ 0, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],
[ 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1]],
[[12, 13, 14, 15, 16, 17, 1, 1, 1, 1, 1, 1],
[18, 19, 20, 21, 22, 23, 1, 1, 1, 1, 1, 1]],
[[24, 25, 26, 27, 28, 29, 1, 1, 1, 1, 1, 1],
[30, 31, 32, 33, 34, 35, 1, 1, 1, 1, 1, 1]]]),
array([[[ 0, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],
[ 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1]],
[[12, 13, 14, 15, 16, 17, 1, 1, 1, 1, 1, 1],
[18, 19, 20, 21, 22, 23, 1, 1, 1, 1, 1, 1]],
[[24, 25, 26, 27, 28, 29, 1, 1, 1, 1, 1, 1],
[30, 31, 32, 33, 34, 35, 1, 1, 1, 1, 1, 1]],
[[36, 37, 38, 39, 40, 41, 1, 1, 1, 1, 1, 1],
[42, 43, 44, 45, 46, 47, 1, 1, 1, 1, 1, 1]]])], dtype=object)