Replacing entire elements in an array

  numpy, python

Question
Let’s say I have the following array tile1

[[80 80 80]
  [80 80 80]
  [80 80 80]
  [80 80 80]]

I want to replace every [80 80 80] element with the array [1 5 10]. How can I do that?

What I have tried

I tried

print(tile1==[80,80,80])

And I thought that was pretty useful but then I realized that is the same as

print(tile1==80)

So when I tried

tile1[tile1==[80,80,80]]=[1,5,10]

of course it failed. I could only assign values based on basic elements like tile1[tile1==[80,80,80]]=5

Source: Python Questions

LEAVE A COMMENT