Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32c0b78

Browse filesBrowse 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 4a5051f commit 32c0b78
Copy full SHA for 32c0b78

File tree

1 file changed

+6
-1
lines changed
Filter options

1 file changed

+6
-1
lines changed

‎pandas/core/reshape/pivot.py

Copy file name to clipboardExpand all lines: 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.