← aggregate_invocation operator page · aggregate/aggregate_invocation/group_by/manual_ex_1
pandas ✅ · DuckDB ✅
avg at data set level grouped by Id_1, on an operand with the non-viral attribute At_1.
Aggregate invocation, Example 1, output verbatim: "For invocation at Data Set level, the Attribute propagation rule is applied".
At_1 is dropped, as a non-viral attribute; 2010 gives (20 + 1 + 1 + 23) / 4 = 11.25, 2011 gives 10 and 2012 gives 35.
the script comments its two alternative forms with #, which is the membership operator, not a VTL comment. The manual's conventions define /* */ and //, so they are commented with // here.
DS_r := avg ( DS_1 group by Id_1 ); // Or equivalently: // DS_r := avg ( DS_1 group except Id_2, Id_3 ) // DS_r := avg ( DS_1#Me_1 group by Id_1 )
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 2010 | E | XX | 20 | |
| 2010 | B | XX | 1 | H |
| 2010 | R | XX | 1 | A |
| 2010 | F | YY | 23 | |
| 2011 | E | XX | 20 | P |
| 2011 | B | ZZ | 1 | N |
| 2011 | R | YY | -1 | P |
| 2011 | F | XX | 20 | Z |
| 2012 | L | ZZ | 40 | P |
| 2012 | E | YY | 30 | P |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Time_Period", "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 | Me_1 |
|---|---|
| 2010 | 11.25 |
| 2011 | 10.0 |
| 2012 | 35.0 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
{"name": "Me_1", "type": "Number", "role": "Measure"}
]
}
]
}