Add a sequential counter column on groups to a pandas dataframe I feel like there is a better way than this: