← sum operator page · aggregate/sum/ds_group_by/manual_ex_1
pandas ✅ · DuckDB ✅
sum at data set level grouped by Id_1, over one Integer measure.
Sum, Example 1, with the manual's data points: "The operator returns the sum of the input values."
15 for 2011 and 6 for 2012. Me_1 may be Integer, as the manual prints it, or Number: the page says "implementations may preserve the integer type for the resulting measure or component when all operand values are integer and the sum is computed in integer arithmetic".
DS_r := sum ( DS_1 group by Id_1 );
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| 2011 | A | XX | 3 |
| 2011 | A | YY | 5 |
| 2011 | B | YY | 7 |
| 2012 | A | XX | 2 |
| 2012 | B | YY | 4 |
{
"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}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 2011 | 15 |
| 2012 | 6 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
{"name": "Me_1", "type": ["Integer", "Number"], "role": "Measure"}
]
}
]
}