Move pytables reductions to a single function