← unpivot operator page · clause/unpivot/basic/manual_ex_1
pandas ✅ · DuckDB ✅
unpivot Id_2, Me_1, on the Integer measures A, B and C.
Unpivoting, Example 1, output verbatim: "The VDS identifier is assigned a value equal to the name of the Measure M of op", and "The VDS measure is assigned a value equal to the value of the Measure M of op".
Six data points, one per data point and measure: Id_2 holds A, B or C and Me_1 its value, such as (1, A) = 5 and (2, C) = 9.
DS_r := DS_1 [ unpivot Id_2, Me_1 ];
| Id_1 | A | B | C |
|---|---|---|---|
| 1 | 5 | 2 | 7 |
| 2 | 3 | 4 | 9 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "A", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "B", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "C", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 2 | A | 3 |
| 1 | B | 2 |
| 2 | B | 4 |
| 1 | C | 7 |
| 2 | C | 9 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}