ENH: add bounds-checking preamble to groupby_X cython code

continues #3017, does an easier bit under #3028