← sub operator page · clause/sub/one_id/manual_ex_3
pandas ✅ · DuckDB ✅
DS_1 [ sub Id_2 = "A" ] + DS_1 [ sub Id_2 = "B" ]: two subspaces on one identifier, added.
Subspace, Example 3, output verbatim: "It maintains the Data Points of VDS for which identifier = value", then "It projects out (“drops”, in VTL terms) all the identifier (s)".
Both subspaces have Id_1 and Id_3, and the sum pairs their data points on them: (1,XX) = 20 + 4 = 24, (1,YY) = 10, (2,XX) = 19 and (2,YY) = 20. At_1 is non-viral, so the sum does not keep it: "the non-viral Attributes are not kept in the result" (User Manual).
DS_r := DS_1 [ sub Id_2 = "A" ] + DS_1 [ sub Id_2 = "B" ];
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | XX | 20 | F |
| 1 | A | YY | 1 | F |
| 1 | B | XX | 4 | E |
| 1 | B | YY | 9 | F |
| 2 | A | XX | 7 | F |
| 2 | A | YY | 5 | E |
| 2 | B | XX | 12 | F |
| 2 | B | YY | 15 | F |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "At_1", "type": "String", "role": "Attribute", "nullable": true}
]
}
]
}
| Id_1 | Id_3 | Me_1 |
|---|---|---|
| 1 | XX | 24 |
| 1 | YY | 10 |
| 2 | XX | 19 |
| 2 | YY | 20 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_3", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}