Subquery With Group By Pandas Average