How to group sorted rows not having any duplicates?

I'm trying to group "consecutively different" rows like here. So, I'm not trying to remove duplicates, but want to group sorted rows not having any duplicates and then count the elements of each group.

Below are all F1 races and winners from 1960-1962. "first" and "last" refer to the first result found on the website above.

Can anybody perhaps give me an example for this?

race_id driver              driver_id
746     Bruce McLaren       360
747     Stirling Moss       475
748     Jim Rathmann        509
749     Jack Brabham        356
750     Jack Brabham        356
751     Jack Brabham        356
752     Jack Brabham        356
753     Jack Brabham        356
754     Phil Hill           403
755     Stirling Moss       475
738     Stirling Moss       475
739     Wolfgang von Trips  476 -- first
740     Phil Hill           403
741     Giancarlo Baghetti  394
742     Wolfgang von Trips  476
743     Stirling Moss       475
744     Phil Hill           403
745     Innes Ireland       404
729     Graham Hill         289
730     Bruce McLaren       360
731     Jim Clark           373
732     Dan Gurney          364 -- last
733     Jim Clark           373
734     Graham Hill         289
735     Graham Hill         289
736     Jim Clark           373
737     Graham Hill         289