How to fill an NPArray with another array starting at a key in Python?
问题 I have a dataframe, called x . This consists of 2 columns which looks like this (712, 2): SibSp Parch 731 0 0 230 1 0 627 0 0 831 1 1 391 0 0 ................. Due to logistic regression needing a 'free weight', I build a newX variable with the shape of my x data frame but blank values. newX = np.zeros(shape=(x.shape[0], x.shape[1] + 1)) This generates a (712, 3) np array: [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.] ... [0. 0. 0.] [0. 0. 0.] [0. 0. 0.]] Since the first index (0) is a free weight, I