Say I have this array:
array = np.array([[1,2,3],[4,5,6],[7,8,9]])
returns:
123
456
789
How should I go about getting it to do something like this
returns:
111222333
111222333
111222333
444555666
444555666
444555666
777888999
777888999
777888999
I don’t know what to google to get an answer as all of my results have been different issues since I imagine this isn’t too common of a thing
Anyway, any and all help would be greatly appreciated 🙂
>Solution :
You’d have to use np.repeat
twice here.
np.repeat(np.repeat(array, 3, axis=1), 3, axis=0)
# [[1 1 1 2 2 2 3 3 3]
# [1 1 1 2 2 2 3 3 3]
# [1 1 1 2 2 2 3 3 3]
# [4 4 4 5 5 5 6 6 6]
# [4 4 4 5 5 5 6 6 6]
# [4 4 4 5 5 5 6 6 6]
# [7 7 7 8 8 8 9 9 9]
# [7 7 7 8 8 8 9 9 9]
# [7 7 7 8 8 8 9 9 9]]