I'm having a very hard time appending my x_ array to x while maintaining the correct shape. I tried vstack, but it gave me an error. The axis=0 doesn't seem to be doing anything like it's supposed to. I want an array with dimension (:,len(x_)).
Edit:
The code at the end of the post gives arrays x_ of the following shape:
array([3, 0, 2, 1, 0], dtype=int32)
I tried:
x_ = np.append(x_,np.array([5,4,6,7,8]), axis = 0)
But gives:
array([3, 0, 2, 1, 0, 5, 4, 6, 7, 8])
However, I want:
array([[3, 0, 2, 1, 0],
[5, 4, 6, 7, 8]])
I tried vstack(x,x_), but got:
x = np.vstack(x, x_)
TypeError: vstack() takes 1 positional argument but 2 were given
.
for k in range(2,9):
temp_ = (2*k)+1
x = np.zeros(shape=(1,temp_))
y = []
for i in range(k, len(number_list)-k-1):
newk = k
x_ = []
while newk >= -k:
x_.append(name[i-newk])
newk-=1
le = preprocessing.LabelEncoder()
le.fit(x_)
x_ = le.transform(x_)
x = np.append(x, x_ , axis=0)
y.append(residue_area[i])
np.concatenate. It requires correct array shapes, and doesn't try to compensate or second guess your intentions.