Say I have this array
x = np.array([0,0,0
1,1,1
2,2,2])
and
y = np.array([4,5,6])
I'd like x to become
[4,4,4
5,5,5
6,6,6]
meaning, i in x becomes y[i]. I have a feeling fancy indexing will be my help, but I'm new to numpy and struggling.
input;
[[ 0 0 0 ... 255 255 255]
[ 0 0 0 ... 255 255 255]
[ 0 0 0 ... 255 255 255]
...
[ 0 0 0 ... 255 255 255]
[ 0 0 0 ... 255 255 255]
[ 0 0 0 ... 255 255 255]]
and my desired output, given y of length 256, y = np.array([5,6,7.......261])
[[ 5 ... 261]
[ 5 ... 261]
[ 5 ... 261]
...
[ 5 ... 261]
[ 5 ... 261]
[ 5 ... 261]]