Push selects through apply and groupby

Resolves #188 and #190