Say I've got two numpy arrays which were created this way:
zeros = np.zeros((270,270))
ones = np.ones((150,150))
How can I insert ones
in zeros
at position [60,60]
?
I want an array that looks like a "square in the square".
I've tried the following two options:
np.put(empty, [60,60], ones)
np.put(empty, [3541], ones)
np.put[empty, [60:210,60:210], ones)
but the latter yields invalid syntax and the first two don't work either. Has anyone got an idea how this could work?
This is one way you can replace values in zeros with ones.
zeros[60:210,60:210] = ones
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With