Note that siuba expects to put grouping columns on a summarize result by resetting the index. However, when group_keys is set to false, resetting the index fails.
from siuba.data import mtcars
from siuba import summarize
mtcars.groupby("cyl", group_keys=False).apply(lambda df: summarize(df, res=_.mpg.mean()))
# note no cyl on index
res
0 26.663636
0 19.742857
0 15.100000
We should just have a grouped summarize set group_keys to true. It seems like we should also be checking whether any result columns have overridden grouping columns, and ensure that doesn't raise an error.
Note that siuba expects to put grouping columns on a summarize result by resetting the index. However, when group_keys is set to false, resetting the index fails.
We should just have a grouped summarize set group_keys to true. It seems like we should also be checking whether any result columns have overridden grouping columns, and ensure that doesn't raise an error.
For example, this works in dplyr: