This is some fairly non-obvious numpy shorthand, that deserves some comments.  e.g. why the [0] at the end?  I guess where must return a tuple or something, so what is the first element that you are saving as zeroindex?  Should also explain the next line in words.  I think I figured out how it works, but it definitely deserves some explanation in English why the diff==1 and why the +1 at the end.