Mergedpandas-dev/pandas#7138450.3Kstars
DOC: Fix stack and from_dummies descriptions in the reshaping guide
By Mohd Maaz Khan, merged by jbrockmendel into pandas-dev/pandas on 31 Oct 2026
Conversation
maaz7409opened this pull request on 20 Oct 2026description.mdAuthor - I have reviewed and followed all the contribution guidelines
This PR fixes descriptions in three places in
user_guide/reshaping.rstwhich describe the wrong result:-
(i)
stack(line 208): "The stacked level becomes the new lowest level in aMultiIndexon the columns".stackmoves the level into the row index. For columns(exp, animal),df.stack("animal")gives an index of(first, second, animal), and onlyexpstays on the columns. The bullet at the top of the same section already says "an index with a new inner-most level of row labels". This PR uses that wording. -
(ii) Round-trip check (line 251):
all(df.unstack().stack() == df.sort_index())calls the builtinall()on a DataFrame, which iterates the column labels (["A"]), not the values. It isTrueeven when the frames differ:all((df + 1) == df)is alsoTrue. This PR changes it todf.unstack().stack().equals(df.sort_index()), which compares the values, the index and the dtypes. That is what the sentence above the example claims. -
(iii)
from_dummies(line 495): "back into aSeriesof categorical values".from_dummiesreturns aDataFrame(signature-> DataFrame, docstring "Create a categoricalDataFrame"). The example directly below already shows a one-column frame,prefix. This PR changesSeriestoDataFrame.
AI Disclosure: Claude Code ( Sonnet 5.5 (high) ) was used for auditing docs and pointing out these issues.
maaz7409commented on 20 Oct 2026Author /pandas-reviewwith Opus 5.5 at high effortjbrockmendelapproved these changes on 31 Oct 2026
jbrockmendelcommented on 31 Oct 2026Member thanks @maaz7409
jbrockmendelmerged this pull request on 31 Oct 2026
Copied from GitHub when this site was built; comments by bots are left out.