Does the aggregate function in pandas groupby treat builtin functions differently?
This behaviour seems to have changed by now. At least here in version 0.23.0, both lambda x: set(x)
and set
behave identically:
In [6]: x.groupby('cat1').agg(set)Out[6]: cat2cat1A {Y, X}B {Y}C {Y, Z}In [7]: x.groupby('cat1').agg(lambda x: set(x))Out[7]: cat2cat1A {Y, X}B {Y}C {Y, Z}
I could not positively identify the change, but bug #16405 looks suspiciously related (although the fix was already released with 0.20.2 in June 2017, long before this question...).