0

I want to create a array of arrays using numpy.full, but i get a error if I set the fill to [1, 1, 1, 1]. Doing the lines below gives this error

size = (20, 20)
npArray = np.full(size, [1, 1, 1, 1])    
ValueError: could not broadcast input array from shape (4) into shape (20,20)

Should I just use python like so

list = [[[1, 1, 1, 1] for y in range(size[1])] for x in range(size[0])]
2
  • Did you mean np.full(size+(4,), [1, 1, 1, 1])? Commented Apr 21, 2017 at 10:05
  • @Divakar Thank you, silly mistake from me :) Commented Apr 21, 2017 at 10:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.