Answers for "append a zeros column numpy"

1

append a zeros column numpy

np.concatenate((np.zeros((3,3), dtype=int), arr), axis=1)
array([[0, 0, 0, 1, 2, 3],
       [0, 0, 0, 4, 5, 6],
       [0, 0, 0, 7, 8, 9]])
Posted by: Guest on July-16-2020
1

add a new column to numpy array

import numpy as np
N = 10
a = np.random.rand(N,N)
b = np.zeros((N,N+1))
b[:,:-1] = a
Posted by: Guest on May-12-2020

Python Answers by Framework

Browse Popular Code Answers by Language