I have a while statement that produces an array in numpy
while(i<int(sp)):
body=(np.bincount(un[i].ravel().astype('int'), weights=step_periods[i].ravel()))
print(body)
i=i+1
each iteration produces an array of like the following:
1st [ 0. 0. 0. 30.]
2nd [ 0. 0. 21. 18. 15.]
3rd [ 0. 24. 27. 0. 3.]
My first issue is that if the first array has "0" as the last value, it will leave it out of the array. Is there a way to convert it from:
[ 0. 0. 0. 30.]
to:
[ 0. 0. 0. 30. 0.]
From there I would like to simply append each array to a master array so that the final output is something similar to:
[[ 0. 0. 0. 30. 0.0],
[ 0. 0. 21. 18. 15.],
[ 0. 24. 27. 0. 3.]]
I've looked into appending and vstack, but can't get it to work in a "while" statement, or possibly because they aren't all the same size due to the ending "0" being ommited!
Thanks!
whileloop that is generating these subarrays.numpyexpert... butfrom itertools import izip_longest; np.vstack(izip_longest(a, b, c, fillvalue=0.)).Tworks... - requires Py2.6+ I believe...