Fold multiple columns¶
This processor takes values from multiple columns and transforms them to one line per column.
For example, with the following dataset representing monthly scores:
person | age | 01/2014 | 02/2014 | 03/2014 |
---|---|---|---|---|
John | 24 | 3 | 4 | 3 |
Sidney | 31 | 6 | 9 | |
Bill | 33 | 1 | 4 |
We would like to get one line per (month, person) couple with the score.
Applying the processor with:
- 3 columns in the “columns list”: 01/2014, 02/2014, 03/2014
- “month” as the “fold name column”
- “score” as the “fold value column”
will generate the following result:
person | age | month | score |
---|---|---|---|
John | 24 | 01/2014 | 3 |
John | 24 | 02/2014 | 4 |
John | 24 | 03/2014 | 6 |
Sidney | 31 | 01/2014 | |
Sidney | 31 | 02/2014 | 6 |
Sidney | 31 | 03/2014 | 9 |
Bill | 33 | 01/2014 | 1 |
Bill | 33 | 02/2014 | |
Bill | 33 | 03/2014 | 4 |
- The names of the folded columns are used as values of the “fold name column”
- The values of the folded columns are used as values of the “fold values column”
- The folded columns are removed
- All other columns are copied
- Empty values are preserved in the folded result
For more details on reshaping, please see Reshaping.