I am trying to generate a set of an array using the code below.I will try to explain what I have done too
First:
example = np.zeros(8,dtype=int)
print(example)
which gave me output:
[0 0 0 0 0 0 0 0]
then:
input=np.array([],int)
for i in range(0,8):
if i <8:
example[i-1]=0
example[i]=1
print(example)
input = np.append(input,example)
print(input)
which then gave me:
[0 1 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1]
and atlast i do this
input = np.append(input,example)
which gives me: [1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1]
but here's how I want this:
[[1 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1]]
or something like that. now, I tried to search, I get errors for whatever I try.hope I get as soon as possible.
np.appenddocs (carefully enough)! As documented it is flattening the inputs.np.appendis not a clone of the list append. Don't try use it in the same way. Better yet don't use it at all. Too many pitfalls for the beginner.