Skip to content

Commit 9b4a5a8

Browse files
authored
Fixed TYP of values argument of the pandas.DataFrame.pivot_table (pandas-dev#893)
* pandas-dev#885 Added Sequence[_str] to the values argument in the stub * Added the test case test_types_pivot_table() for the changed TYP of values argument in pivot_table * Changed the argument values for the test case test_types_pivot_table * Fixed formatting with black
1 parent ce1d7e1 commit 9b4a5a8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pandas-stubs/core/frame.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ class DataFrame(NDFrame, OpsMixin):
11251125
) -> DataFrame: ...
11261126
def pivot_table(
11271127
self,
1128-
values: _str | None = ...,
1128+
values: _str | None | Sequence[_str] = ...,
11291129
index: _str | Grouper | Sequence | None = ...,
11301130
columns: _str | Grouper | Sequence | None = ...,
11311131
aggfunc=...,

tests/test_frame.py

+18
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,24 @@ def test_types_pivot() -> None:
932932
)
933933

934934

935+
def test_types_pivot_table() -> None:
936+
df = pd.DataFrame(
937+
data={
938+
"col1": ["first", "second", "third", "fourth"],
939+
"col2": [50, 70, 56, 111],
940+
"col3": ["A", "B", "C", "D"],
941+
"col4": [100, 102, 500, 600],
942+
}
943+
)
944+
check(
945+
assert_type(
946+
df.pivot_table(index="col1", columns="col3", values=["col2", "col4"]),
947+
pd.DataFrame,
948+
),
949+
pd.DataFrame,
950+
)
951+
952+
935953
def test_types_groupby() -> None:
936954
df = pd.DataFrame(data={"col1": [1, 1, 2], "col2": [3, 4, 5], "col3": [0, 1, 0]})
937955
df.index.name = "ind"

0 commit comments

Comments
 (0)