@@ -13019,18 +13019,17 @@ def stack(
1301913019 axis, defined as one index or label, or a list of indices
1302013020 or labels.
1302113021 dropna : bool, default True
13022- Whether to drop rows in the resulting Frame/Series with
13023- missing values. Stacking a column level onto the index
13024- axis can create combinations of index and column values
13025- that are missing from the original dataframe. See Examples
13026- section.
13022+ .. deprecated:: 3.0
13023+ This parameter is deprecated and no longer has any effect.
13024+ It will be removed in a future version.
1302713025 sort : bool, default True
13028- Whether to sort the levels of the resulting MultiIndex.
13026+ .. deprecated:: 3.0
13027+ This parameter is deprecated and no longer has any effect.
13028+ It will be removed in a future version.
1302913029 future_stack : bool, default True
13030- Whether to use the new implementation that will replace the current
13031- implementation in pandas 3.0. When True, dropna and sort have no impact
13032- on the result and must remain unspecified. See :ref:`pandas 2.1.0 Release
13033- notes <whatsnew_210.enhancements.new_stack>` for more details.
13030+ .. deprecated:: 3.0
13031+ This parameter is deprecated and no longer has any effect.
13032+ It will be removed in a future version.
1303413033
1303513034 Returns
1303613035 -------
@@ -13048,11 +13047,15 @@ def stack(
1304813047
1304913048 Notes
1305013049 -----
13051- The function is named by analogy with a collection of books
13052- being reorganized from being side by side on a horizontal
13053- position (the columns of the dataframe) to being stacked
13054- vertically on top of each other (in the index of the
13055- dataframe).
13050+ Starting from pandas 3.0, ``stack`` always uses the new implementation
13051+ that previously required ``future_stack=True``. The parameters ``dropna``,
13052+ ``sort``, and ``future_stack`` are deprecated and no longer have any effect.
13053+ They will be removed in a future version of pandas.
13054+
13055+ The function is named by analogy with a collection of books being
13056+ reorganized from lying side-by-side horizontally (the columns of the
13057+ DataFrame) to being stacked vertically on top of each other (in the
13058+ index of the DataFrame).
1305613059
1305713060 Reference :ref:`the user guide <reshaping.stacking>` for more examples.
1305813061
@@ -13107,10 +13110,10 @@ def stack(
1310713110 ... [[1.0, 2.0], [3.0, 4.0]], index=["cat", "dog"], columns=multicol2
1310813111 ... )
1310913112
13110- It is common to have missing values when stacking a dataframe
13111- with multi-level columns, as the stacked dataframe typically
13112- has more values than the original dataframe. Missing values
13113- are filled with NaNs:
13113+ When stacking a DataFrame with multi-level columns, the new
13114+ implementation does not generate rows of missing values. The
13115+ result includes only combinations that exist in the original
13116+ data.
1311413117
1311513118 >>> df_multi_level_cols2
1311613119 weight height
0 commit comments