Login
Back to bricks list
Introduction Version

Melt

TASK
Typing name :  TASK.gws_core.Melt Brick :  gws_core

pandas.melt, Unpivot a DataFrame from wide to long format, optionally leaving identifiers set.

Melt from pandas

input : Table

output : Table

Unpivot a DataFrame from wide to long format, optionally leaving identifiers set.

This function is useful to massage a DataFrame into a format where one or more columns are identifier variables (id_vars), while all other columns, considered measured variables (value_vars), are “unpivoted” to the row axis, leaving just two non-identifier columns, 'variable' and 'value'. Do not handle multi-index columns.

Input

input_table
2d excel like table

Output

output_table
2d excel like table

Configuration

id_vars

Optional

Column(s) to use as identifier variables.

Type : list

value_vars

Optional

Column(s) to unpivot. If not specified, uses all columns that are not set as *id_vars*.

Type : list

var_name

Optional

Name to use for the 'variable' column. If None it uses `frame.columns.name` or 'variable'.

Type : string

value_name

Optional

Name to use for the 'value' column.

Type : stringDefault value : value

col_level

Optional

If columns are a MultiIndex then use this level to melt.

Type : string

ignore_index

Optional

If True, original index is ignored. If False, the original index is retained. Index labels will be repeated as necessary.

Type : boolDefault value : true