Support built-in names for Pandas GroupBy-Agg operations in Thicket's GroupBy
- Dominant language
- JavaScript
- Stars
- 18
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
In docstrings and docs, we refer users to pandas for documentation on aggregation functions. Despite this, we do not currently support an important way of specifying aggregation functions: string function names.
For example, currently, to use a "mean" operation in aggregation, we require users to do the following:
```python
gb = thicket_obj.groupby(...)
gb.agg(numpy.mean)
```
In comparison, it is much more common to do the following for a pandas Groupby-Aggregate:
```python
df.groupby(...).agg("mean")
```
We should also support string inputs to our `GroupBy.agg` method to be consistent with pandas.
Beyond consistency, there are 2 other reasons to do this:
1. The logic behind a pandas mean (or similar operations) and a NumPy mean (or equivalent operations) are **not** the same. Current versions of pandas work around this by internally detecting when you pass NumPy functions in and replacing them with pandas' equivalents.
2. Future versions of pandas (i.e., 3.0) will no longer replace NumPy functions with pandas' equivalents. That means there will be implications (e.g., performance) for using `"mean"` over `numpy.mean`. The behavior of the two **will** be different, and the NumPy functions _may_ not produce correct output.
Contributor guide
Research direction
Start at the GroupBy.agg method named in the issue and inspect how aggregation inputs are currently handled. Compare the existing callable behavior with pandas GroupBy.agg examples, especially the string "mean" form. Done means string function names are accepted consistently with the documented pandas-style usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, pandas, python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100