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

Missing parameter for the sort argument of the pandas.DataFrame.pivot_table method #1076

Open
zepaz opened this issue Dec 23, 2024 · 1 comment
Labels
DataFrame DataFrame data structure good first issue

Comments

@zepaz
Copy link

zepaz commented Dec 23, 2024

Missing parameter for the sort argument of the pandas.DataFrame.pivot_table method

Describe the bug The sort argument of the pandas.DataFrame.pivot_table method is available, but according to the pandas-stubs it is not:

def pivot_table(
self,
values: _str | None = ...,
index: _str | Grouper | Sequence | None = ...,
columns: _str | Grouper | Sequence | None = ...,
aggfunc=...,
fill_value: Scalar | None = ...,
margins: _bool = ...,
dropna: _bool = ...,
margins_name: _str = ...,
observed: _bool = ...,
) -> DataFrame: ...

The Pandas documentation says that sort is an available parameter: Docs of pandas.DataFrame.pivot_table

sort bool, default True
    Specifies if the result should be sorted.
    New in version 1.3.0.

To Reproduce
1. A minimal runnable pandas example that is not properly checked by the stubs:

from pandas import DataFrame

data_frame = DataFrame({
    'a': [1, 2],
    'b': [1, 2],
    'c': [1, 2],
    'd': [1, 2],
})
data_frame.pivot_table(
    values=['a', 'b'],
    index=['c', 'd'],
	sort=True,
)
3. I am using `pyright`.

4. The error message received from `pyright`:
9 - error: No parameter named "sort" (reportCallIssue)

Please complete the following information:
* OS: Windows
* OS version: 10
* python version: 3.12.1
* pyright version: 1.1.391
* pandas-stubs version: 2.2.3.241126

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Dec 23, 2024

Thanks for the report. PR with test welcome.

The original stubs were generated a few years ago by a team from Microsoft, prior to version 1.3, which is when sort was added, so that's why it is missing.

@Dr-Irv Dr-Irv added DataFrame DataFrame data structure good first issue labels Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFrame DataFrame data structure good first issue
Projects
None yet
Development

No branches or pull requests

2 participants