Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to fill numpy array between two specific values

$
0
0

I have to fill np array in row 2 with values from row 0.Array looks like that:

[[3. 4. 5. 6. 7. 8. 9. 8. 7. 6.] [0. 0. 1. 0. 0. 1. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]] 

Finally it should looks like bellow

[[3. 4. 5. 6. 7. 8. 9. 8. 7. 6.] [0. 0. 1. 0. 0. 1. 0. 0. 0. 0.] [5. 5. 5. 8. 8. 8. 6. 6. 6. 6.]]

That means:

First row determine points of change. From beginning of row 3 to place where first value "1" in row 2, the row 3 should have value from row 0 where in row two occurs first value "1" and so on..

There is something similar but not exactly what i need.Fill values in numpy array that are between a certain value

Do you know how to do it without iterate over columns?


Viewing all articles
Browse latest Browse all 12111

Trending Articles