Skip to content

Commit 5532e9e

Browse files
authored
fix for DataFrameGroupBy.value_counts (#1257)
1 parent 709d745 commit 5532e9e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pandas-stubs/core/groupby/generic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT, _TT]):
272272
@overload
273273
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
274274
self, key: Iterable[Hashable]
275-
) -> DataFrameGroupBy[ByT, bool]: ...
275+
) -> DataFrameGroupBy[ByT, _TT]: ...
276276
def nunique(self, dropna: bool = ...) -> DataFrame: ...
277277
def idxmax(
278278
self,

tests/test_groupby.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,3 +1093,12 @@ def test_series_value_counts() -> None:
10931093
Series,
10941094
np.float64,
10951095
)
1096+
1097+
1098+
def test_dataframe_value_counts() -> None:
1099+
df = DataFrame({"a": [1, 1, 2], "b": [4, 5, 6], "c": [5, 5, 2]})
1100+
check(
1101+
assert_type(df.groupby("a")[["b", "c"]].value_counts(), "Series[int]"),
1102+
Series,
1103+
np.int64,
1104+
)

0 commit comments

Comments
 (0)