You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BUG: pivot with array-like index/columns labels (GH#35785)
In the no-values path, `cols + columns_listlike` combined the label
arguments elementwise, so an ndarray/Index/Series/ExtensionArray of valid
column labels raised instead of being used as labels; a Series or
ExtensionArray also reached `unstack` unconverted. Convert `index` and
`columns` to plain lists once and reuse them.
The label check added in GH#66311 converted `index`/`values` a second
time, exhausting a one-shot iterator so the body saw an empty sequence,
and it rejected an unhashable entry of the `index` list even though
`set_index` takes that as a column of level values.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v3.1.0.rst
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -594,6 +594,7 @@ Reshaping
594
594
- Bug in :meth:`DataFrame.combine` raising ``OverflowError`` when the combining function returned a value too large for the columns' common integer dtype (e.g. ``2**64``) instead of keeping the result (:issue:`66394`)
595
595
- Bug in :meth:`DataFrame.melt` where ``var_name`` colliding with an ``id_vars`` column or ``value_name`` silently overwrote the affected column data instead of raising (:issue:`65654`)
596
596
- Bug in :meth:`DataFrame.pivot_table` with ``margins=True`` raising ``TypeError`` when ``values`` has an :class:`ExtensionDtype` that cannot hold ``NA`` (e.g. :class:`IntervalDtype` with an integer subtype) and no ``columns`` were specified (:issue:`55484`)
597
+
- Bug in :meth:`DataFrame.pivot` and :func:`pivot` raising ``TypeError`` or ``ValueError`` when ``index`` or ``columns`` was given as an array-like of column labels, e.g. a ``numpy.ndarray``, :class:`Index`, or :class:`Series`, or when ``values`` was given as an iterator of column labels (:issue:`35785`)
597
598
- Bug in :meth:`DataFrame.select_dtypes` where a nullable extension dtype name such as ``"Int64"`` or ``"boolean"`` also selected numpy columns sharing the same scalar type; it now selects only columns of that extension dtype (:issue:`40234`)
598
599
- Bug in :meth:`DataFrame.select_dtypes` where an interval spec giving a subtype but no ``closed`` keyword, such as ``"interval[int64]"`` or ``pd.IntervalDtype("int64")``, selected no columns; it now selects every interval column with that subtype, for any ``closed`` value (:issue:`40234`)
599
600
- Bug in :meth:`DataFrame.select_dtypes` where the string form of an Arrow dtype such as ``"int64[pyarrow]"`` selected no columns and ``"float64[pyarrow]"`` selected numpy float columns; an Arrow dtype string now selects only columns of that exact dtype (:issue:`59888`)
0 commit comments