Skip to content

Commit 1509123

Browse files
committed
modified: pandas/core/reshape/pivot.py
- Added ignore-comment to silence mypy error in :func:`__internal_pivot_table`. - Added TODO-comment stating that the :meth:`DataFrameGroupBy.__getitem__` should be overloaded to match the pandas-stubs type declarations, informing mypy that the type is correct given `values` is a list.
1 parent 63ebc9b commit 1509123

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: pandas/core/reshape/pivot.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ def __internal_pivot_table(
339339
if values_passed:
340340
# GH#57876 and GH#61292
341341
# Explicitly aggregate ``values``.
342-
grouped = grouped[values]
342+
grouped = grouped[values] # type: ignore[assignment]
343+
# TODO: ``grouped`` will have type ``DataFrameGroupBy`` because
344+
# ``values`` is guaranteed to be a ``list[Any]`` per above
345+
# logic. The type hints for ``DataFrameGroupBy`` require an
346+
# overload for mypy to determine this. See stubs in pandas-stubs.
347+
# https://github.com/pandas-dev/pandas-stubs/blob/8434bde95460b996323cc8c0fea7b0a8bb00ea26/pandas-stubs/core/groupby/generic.pyi#L222
343348

344349
agged = grouped.agg(aggfunc, **kwargs)
345350

0 commit comments

Comments
 (0)