Skip to content

groupby(...).transform is untyped #438

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

Closed
rhshadrach opened this issue Nov 23, 2022 · 4 comments · Fixed by #455
Closed

groupby(...).transform is untyped #438

rhshadrach opened this issue Nov 23, 2022 · 4 comments · Fixed by #455
Labels

Comments

@rhshadrach
Copy link
Member

Describe the bug
SeriesGroupBy.transform and DataFrameGroupBy.transform are currently not typed:

def transform(self, func, *args, **kwargs): ...

Running mypy with --disallow-untyped-calls reports an issue with any usage of this method.

@rhshadrach rhshadrach added Bug Apply Apply, Aggregate, Transform Groupby labels Nov 23, 2022
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 23, 2022

Need to return Series for SeriesGroupBy.transform and DataFrame for DataFrameGroupBy.transform.

PR with tests welcome

@ramvikrams
Copy link
Contributor

Do we not have to change the arguments of transform? will it work if we just add the return types

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 29, 2022

Do we not have to change the arguments of transform? will it work if we just add the return types

For now, you could just annotate f as Callable and don't worry about *args and **kwargs, and then add the return types.

@rhshadrach
Copy link
Member Author

For now, you could just annotate f as Callable

I would do str | Callable; using a string alias is a very common use case (at least for me). Looks like the docs need updating in this regard.

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

Successfully merging a pull request may close this issue.

3 participants