Weird Behavior in Group_By

I think you will need to post a reproducible example in order for us to be able to help you effectively. Maybe you could just sample a few rows from your actual data set since it's very likely that the problem is with your data.