Skip to content

Commit 7e10273

Browse files
Polish examples.
1 parent 310511d commit 7e10273

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pandas/core/frame.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,8 +5217,10 @@ def stack(self, level=-1, dropna=True):
52175217
two a 2
52185218
b 3
52195219
5220-
Stacking a dataframe with a multi-level column axis with no missing values.
5221-
By default the missing values are filled with NaNs:
5220+
It is common to have missing values when stacking a dataframe
5221+
with multi-level columns, since the stacked dataframe can have
5222+
more values than the original dataframe. By default the
5223+
missing values are filled with NaNs:
52225224
52235225
>>> df_multi_level_cols2
52245226
X Y
@@ -5232,14 +5234,15 @@ def stack(self, level=-1, dropna=True):
52325234
two a 2.0 NaN
52335235
b NaN 3.0
52345236
5235-
Rows where all values are missing are dropped by default:
5237+
Rows where all values are missing are dropped by default but
5238+
this behaviour can be controlled via the dropna keyword
5239+
parameter:
52365240
52375241
>>> df_multi_level_cols3
52385242
X Y
52395243
a b
52405244
one NaN 1.0
52415245
two 2.0 3.0
5242-
52435246
>>> df_multi_level_cols3.stack(dropna=False)
52445247
X Y
52455248
one a NaN NaN

0 commit comments

Comments
 (0)