I don't think that understanding is correct: in order to reach the next key in `groupby`, it has to have iterated until it finds the next one. So your original iterator has already been consumed.