REF: casting in _python_agg_general
Consolidate two for-loops into one.

Instead of using maybe_cast_result in two places, use it only once, immediately after the function call being wrapped.  Replace those two usages with the less-invasive `maybe_downcast_to_dtype`
looks like between this and the other groupby-casting PR we caused an unused import in groupby.py.  I'll push a fix to the next PR I rebase