reduceby and countby can accept an index or list of indices as the key

Lesson learned: even inline functions need to return `object` so exceptions can be properly raised.