Skip to content
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

pandas DataFrameGroupby.agg (still) has incomplete signature #2180

Closed
tuchandra opened this issue Dec 16, 2021 · 2 comments
Closed

pandas DataFrameGroupby.agg (still) has incomplete signature #2180

tuchandra opened this issue Dec 16, 2021 · 2 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version needs stub

Comments

@tuchandra
Copy link

I originally put this in a comment on #2080, but I figured I'd make a standalone issue.

Environment data

  • Language Server version: 2021.12.2-pre.1
  • OS and version: darwin x64
  • Python version (and distribution if applicable, e.g. Anaconda): 3.9.9, via pyenv
  • python.analysis.indexing: undefined
  • python.analysis.typeCheckingMode: basic

Expected behaviour

That I can pass two `NamedAgg`s to the `agg` method of `DataFrameGroupBy`.

Actual behaviour

I get an error -
No overloads for "agg" match the provided arguments
  Argument types: (NamedAgg, NamedAgg)PylancereportGeneralTypeIssues

Logs

Python Language Server Log

Background analysis message: setFileOpened
Background analysis message: markFilesDirty
Background analysis message: analyze
[BG(1)] analyzing: Untitled-1 ...
[BG(1)]   parsing: Untitled-1 (5ms)
[BG(1)]   binding: Untitled-1 (2ms)
[BG(1)]   checking: Untitled-1 ...
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/__init__.pyi [fs read 2ms] (15ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/__init__.pyi (1ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/api.pyi [fs read 1ms] (4ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/api.pyi (0ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/frame.pyi [fs read 1ms] (75ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/frame.pyi (14ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/generic.pyi [fs read 1ms] (10ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/generic.pyi (3ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/base.pyi [fs read 1ms] (3ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/base.pyi (1ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/accessor.pyi [fs read 1ms] (1ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/accessor.pyi (0ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/indexing.pyi [fs read 0ms] (1ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/indexing.pyi (0ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/_typing.pyi [fs read 1ms] (4ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/_typing.pyi (1ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/indexes/api.pyi [fs read 1ms] (2ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/indexes/api.pyi (0ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/indexes/base.pyi [fs read 1ms] (4ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/indexes/base.pyi (2ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/series.pyi [fs read 1ms] (17ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/series.pyi (10ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/typeshed-fallback/stdlib/datetime.pyi [fs read 1ms] (6ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/typeshed-fallback/stdlib/datetime.pyi (2ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/groupby/__init__.pyi [fs read 0ms] (1ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/groupby/__init__.pyi (0ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/groupby/generic.pyi [fs read 1ms] (10ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/groupby/generic.pyi (4ms)
[BG(1)]     parsing: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/groupby/groupby.pyi [fs read 1ms] (2ms)
[BG(1)]     binding: /Users/tushar.chandra/.vscode/extensions/ms-python.vscode-pylance-2021.12.3-pre.1/dist/bundled/stubs/pandas/core/groupby/groupby.pyi (3ms)
[BG(1)]   checking: Untitled-1 (248ms)
[BG(1)] analyzing: Untitled-1 (256ms)
Background analysis message: getSemanticTokens delta
[BG(1)] getSemanticTokens delta previousResultId:1639680019523 at Untitled-1 (2ms)
Background analysis message: resumeAnalysis

Code Snippet / Additional information

import pandas as pd

df = pd.DataFrame()
group = df.groupby("x")
reveal_type(group)  # DataFrameGroupBy
agged = group.agg(x=pd.NamedAgg("a", "b"), y=pd.NamedAgg("c", "d"))

image

@bschnurr
Copy link
Member

bschnurr commented Dec 16, 2021

Thanks for the separate issue. the type stub for agg needs to be updated and I also think my previous update to NamedAgg also needs to be updated.

A fix can be submitted here. https://github.com/microsoft/python-type-stubs

@github-actions github-actions bot removed the triage label Dec 16, 2021
@debonte debonte added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Feb 3, 2022
@debonte
Copy link
Contributor

debonte commented Feb 4, 2022

This issue has been fixed in version 2022.2.0, which we've just released. You can find the changelog here: CHANGELOG.md

@debonte debonte closed this as completed Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version needs stub
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants