I am wanting to build some matrices one column at a time, with columns from an existing matrix, as per the code below.
# x is an existing matrix, y is an array, pos_classes is a set for i in range(len(y)): if y[i] in pos_classes: x_pos = np.append(x_pos, x[i]) y_pos_actual = np.append(y_pos_actual, y[i]) else: x_neg = np.append(x_neg, x[i]) y_neg_actual = np.append(y_neg_actual, y[i])
My question is, what should I initialise
x_neg as so that each
x[i] gets appended column-wise? I tried as below, and each append turns
x_pos into a 1D array.
x_pos = np.empty((0,x.shape))
I'm fairly new to python and am probably missing something obvious.