I want to add a new column one by one, and I simplified my code:
import numpy as np
score = [[99], [99]]
for j in range (5):
temp = []
for i in range (2):
temp.append(i)
temp = np.array(temp)
score = np.c_[score, temp.T]
score = np.delete(score, obj=0, axis=1)
print(score)
I want to add a new column [1, 2].T at each step, so that the array looks like this:
[1] -> [1, 1] -> ...
[2] [2, 2]
However, I have to create the first column [[99], [99]] and delete it in the end. Is there some better method can skip this step?
score = np.empty((2, 0)instead of[[99], [99]]. For another, lists and deques are much better at appending than numpy arrays. Your loop is making me cry inside a little.