Skip to content

Create more precise annotations for DataFrame/Series GroupBy operations (agg, apply, transform) #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gandhis1 opened this issue Nov 30, 2022 · 1 comment

Comments

@gandhis1
Copy link
Contributor

All of these groupby operations take a function that can be a str or a Callable. They should ensure that:

  • The Callable accepts a first parameter that is a DataFrame or Series as applicable
  • The Callable returns the appropriate type - in some cases an Iterable, in other cases either a DataFrame or Series
  • If a str is passed in, it is part of the set of supported functions, which are located here: https://github.com/pandas-dev/pandas/blob/main/pandas/core/groupby/base.py#L60
  • If possible - and this may not be possible today - ensure that args and kwargs parameters are type checked against the passed-in Callable
  • Comprehensive set of tests are needed here, to exercise all variations

I'll start with transform because that is a fairly simple API compared to the others and it is not very commonly used, so the potential impact of more narrow types there has a lower risk of an impactful regression.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Dec 5, 2022

For transform, see this line, https://github.com/pandas-dev/pandas/blob/6b0ac938279d2baec210641bfaf3719872f9a187/pandas/core/groupby/base.py#L118 so you have to combine the transform specific ones and the reduction ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants