Я думаю, ты хочешь NumPy repeat()
. Используйте аргумент axis
, чтобы указать, какую ось повторять:
In [1]: x = np.random.randint(1, 10, (5,5))
In [2]: x
Out[2]:
array([[7, 3, 6, 8, 8],
[6, 5, 3, 3, 9],
[1, 7, 1, 5, 7],
[4, 6, 6, 8, 3],
[3, 7, 8, 6, 7]])
In [4]: x.repeat(2, axis=1)
Out[4]:
array([[7, 7, 3, 3, 6, 6, 8, 8, 8, 8],
[6, 6, 5, 5, 3, 3, 3, 3, 9, 9],
[1, 1, 7, 7, 1, 1, 5, 5, 7, 7],
[4, 4, 6, 6, 6, 6, 8, 8, 3, 3],
[3, 3, 7, 7, 8, 8, 6, 6, 7, 7]])
Или, возможно, numpy.tile()
:
In [15]: np.tile(x, 2)
Out[15]:
array([[7, 3, 6, 8, 8, 7, 3, 6, 8, 8],
[6, 5, 3, 3, 9, 6, 5, 3, 3, 9],
[1, 7, 1, 5, 7, 1, 7, 1, 5, 7],
[4, 6, 6, 8, 3, 4, 6, 6, 8, 3],
[3, 7, 8, 6, 7, 3, 7, 8, 6, 7]])