Answers for "python add column to a matrix"

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
0

python add column to a matrix

import numpy as np

X = np.random.uniform(size=(10,3))
n,m = X.shape # for generality
X0 = np.ones((n,1))
Xnew = np.hstack((X,X0))
Posted by: Guest on April-03-2021

Code answers related to "python add column to a matrix"

Python Answers by Framework

Browse Popular Code Answers by Language