BUG: Bug on pivot_table with margins and dict aggfunc (GH8349)