Skip to content

Fixed TYP of values argument of the pandas.DataFrame.pivot_table #893

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

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ class DataFrame(NDFrame, OpsMixin):
) -> DataFrame: ...
def pivot_table(
self,
values: _str | None = ...,
values: _str | None | Sequence[_str] = ...,
index: _str | Grouper | Sequence | None = ...,
columns: _str | Grouper | Sequence | None = ...,
aggfunc=...,
Expand Down
17 changes: 17 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,23 @@ def test_types_pivot() -> None:
)


def test_types_pivot_table() -> None:
df = pd.DataFrame(
data={
"col1": ["first", "second", "third", "fourth"],
"col2": [50, 70, 56, 111],
"col3": ["A", "B", "C", "D"],
"col4": [100, 102, 500, 600],
}
)
check(
assert_type(
df.pivot_table(index="col1", columns="col3", values=["col2", "col4"]), pd.DataFrame,
),
pd.DataFrame,
)


def test_types_groupby() -> None:
df = pd.DataFrame(data={"col1": [1, 1, 2], "col2": [3, 4, 5], "col3": [0, 1, 0]})
df.index.name = "ind"
Expand Down
Loading