How can I create an array based on certain conditions in another array. For example, if I have an array that gives me a Base number, a start and end number, and then multiple other Base numbers. I want to create a new matrix that lists the Base number, the loop number (based on start/end) and then the other Base number associated with this, while ignoring 0's. I am trying to find a way to do this without using a for loop.
For example, how can I get array B from array A.
Base Start End Base1 Base2 Base3
A=np.array([[100, 1, 2, 101, 102, 103],
[101, 3, 4, 100, 103, 0]])
B=np.array[[100,1,101,1],
[100,1,102,1],
[100,1,103,1],
[100,2,101,2],
[100,2,102,2],
[100,2,103,2],
[101,3,100,3],
[101,3,103,3],
[101,4,100,4],
[101,4,103,4]]
Thanks for the help!
numpy.tileandnumpy.repeat, but why go to such lengths to not use a loop?Bend with a1instead of a2? If you post a slow version with explicit loops, that would make it easier for us to understand exactly what you want to do.