I have an array a of increasing indexes, e.g. [2 5 9 10], which indicates positions of value change. Assuming the output values are 0 and 1, I want to get array b: [0 0 1 1 1 0 0 0 0 1 0] Is there a NumPy magic to transform a into b? Continue reading...