If I run the following:
import numpy as np
a = np.arange(9)
a = a.reshape((3,3))
I will get this:
a = [[0 1 2]
[3 4 5]
[6 7 8]]
If I create a larger array like this:
b = np.zeros((5,5))
b = [[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]]
How do I efficiently copy a
into b
to get an array like this?
# border of 0 surrounding a to be filled in with other data later
b = [[ 0. 0. 0. 0. 0.]
[ 0. 0. 1. 2. 0.]
[ 0. 3. 4. 5. 0.]
[ 0. 6. 7. 8. 0.]
[ 0. 0. 0. 0. 0.]]
I am looking for a function built into numpy
if it exists.