how to make a new numpy array same size as a given array and fill it with a scalar value

Viewed 34768

I have a numpy array with some random numbers, how can I create a new array with the same size and fill it with a single value?

I have the following code:

A=np.array([[2,2],
            [2,2]])
B=np.copy(A)
B=B.fill(1)

I want to have a new array B with the same size as A but filled with 1s. However, it returns a None object. Same when using np.full.

1 Answers
Related