Skip to content

Commit f36d7a8

Browse files
committed
DOC: Add documentation for new melt() functionality.
1 parent 359cc3c commit f36d7a8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

doc/source/reshaping.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ Reshaping by Melt
200200
The ``melt`` function found in ``pandas.core.reshape`` is useful to massage a
201201
DataFrame into a format where one or more columns are identifier variables,
202202
while all other columns, considered measured variables, are "pivoted" to the
203-
row axis, leaving just two non-identifier columns, "variable" and "value".
203+
row axis, leaving just two non-identifier columns, "variable" and "value". The
204+
names of those columns can be customized by supplying the ``var_name`` and
205+
``value_name`` parameters.
204206

205207
For instance,
206208

@@ -212,6 +214,7 @@ For instance,
212214
'weight' : [130, 150]})
213215
cheese
214216
melt(cheese, id_vars=['first', 'last'])
217+
melt(cheese, id_vars=['first', 'last'], var_name='quantity')
215218
216219
Combining with stats and GroupBy
217220
--------------------------------

doc/source/v0.11.1.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ Enhancements
138138
import os
139139
os.remove('mi.csv')
140140

141+
- ``pd.melt()`` now accepts the optional parameters ``var_name`` and ``value_name``
142+
to specify custom column names of the returned DataFrame.
143+
141144
Bug Fixes
142145
~~~~~~~~~
143146

pandas/core/reshape.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,10 @@ def melt(frame, id_vars=None, value_vars=None,
609609
Parameters
610610
----------
611611
frame : DataFrame
612-
id_vars :
613-
value_vars :
612+
id_vars : tuple, list, or ndarray
613+
value_vars : tuple, list, or ndarray
614+
var_name : scalar
615+
value_name : scalar
614616
615617
Examples
616618
--------

0 commit comments

Comments
 (0)