Skip to content

Commit 25888c3

Browse files
committed
DOC: Fix outputs in wide_to_long docstring to reflect actual results
1 parent a1f8a63 commit 25888c3

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

pandas/core/reshape/melt.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,15 @@ def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'):
270270
... 'ht2': [3.4, 3.8, 2.9, 3.2, 2.8, 2.4, 3.3, 3.4, 2.9]
271271
... })
272272
>>> df
273-
birth famid ht1 ht2
273+
famid birth ht1 ht2
274274
0 1 1 2.8 3.4
275-
1 2 1 2.9 3.8
276-
2 3 1 2.2 2.9
277-
3 1 2 2.0 3.2
275+
1 1 2 2.9 3.8
276+
2 1 3 2.2 2.9
277+
3 2 1 2.0 3.2
278278
4 2 2 1.8 2.8
279-
5 3 2 1.9 2.4
280-
6 1 3 2.2 3.3
281-
7 2 3 2.3 3.4
279+
5 2 3 1.9 2.4
280+
6 3 1 2.2 3.3
281+
7 3 2 2.3 3.4
282282
8 3 3 2.1 2.9
283283
>>> l = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age')
284284
>>> l
@@ -330,14 +330,10 @@ def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'):
330330
... 'X' : np.random.randint(3, size=3)})
331331
>>> df['id'] = df.index
332332
>>> df # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
333-
A(quarterly)-2010 A(quarterly)-2011 B(quarterly)-2010 ...
334-
0 0.548814 0.544883 0.437587 ...
335-
1 0.715189 0.423655 0.891773 ...
336-
2 0.602763 0.645894 0.963663 ...
337-
X id
338-
0 0 0
339-
1 1 1
340-
2 1 2
333+
A(quarterly)-2010 A(quarterly)-2011 B(quarterly)-2010 B(quarterly)-2011 X id
334+
0 0.548814 0.544883 0.437587 0.383442 0 0
335+
1 0.715189 0.423655 0.891773 0.791725 1 1
336+
2 0.602763 0.645894 0.963663 0.528895 1 2
341337
342338
>>> pd.wide_to_long(df, ['A(quarterly)', 'B(quarterly)'], i='id',
343339
... j='year', sep='-')

0 commit comments

Comments
 (0)