pbeshai / tidy

Tidy up your data with JavaScript, inspired by dplyr and the tidyverse
https://pbeshai.github.io/tidy
MIT License
725 stars 21 forks source link

Should groupBy's addGroupKeys be on by default? #38

Open pbeshai opened 3 years ago

pbeshai commented 3 years ago

Currently groupBy automatically adds group keys back to objects after each function in the flow. This was primarily done to mitigate the fact that summarize (a very common groupBy operation) removes them. There has been some discussion in #34 around whether or not this should be default behavior.

It's a pretty big breaking change to switch to not adding them by default, so I'm not sure it will be worth it. However, it would improve the performance of groupBy and perhaps it is easier to reason about by not adding them (users can always explicitly keep them around when summarizing via first (e.g. summarize({ cyl: first('cyl') })).

An in-between would be to not add them in except for certain exports? It's likely when exporting by entries or object you don't want them added back in. I'm not sure what to do here, and am open to any ideas.