machow / siuba

Python library for using dplyr like syntax with pandas and SQL
https://siuba.org
MIT License
1.14k stars 48 forks source link

fix: across handles sql grouped; handles pandas mutate with aggs #455

Closed machow closed 1 year ago

machow commented 1 year ago

This PR provides two fixes for across()

from siuba.data import cars
from siuba import across, Fx, mutate, head

cars.groupby("cyl") >> mutate(across(_[_.hp, _.mpg], Fx.mean())) >> head()
   cyl        mpg          hp
0    6  19.742857  122.285714
1    6  19.742857  122.285714
2    4  26.663636   82.636364
3    6  19.742857  122.285714
4    8  15.100000  209.214286