← calc operator page · clause/calc/attribute/manual_ex_2
pandas ✅ · DuckDB ✅
calc attribute At_1 := "EP": a new attribute with a constant value.
Calculation of a Component, Example 2, output verbatim: "It is possible to specify the role of the calculated Component among measure, identifier, attribute, or viral attribute", and "If the calculated Component is a new Component, it is added to the output Data Set".
The input, plus the String Attribute At_1 = EP on its three data points.
DS_r := DS_1 [ calc attribute At_1:= "EP" ];
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| 1 | A | CA | 20 |
| 1 | B | CA | 2 |
| 2 | A | CA | 2 |
{
"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}
]
}
]
}
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | CA | 20 | EP |
| 1 | B | CA | 2 | EP |
| 2 | A | CA | 2 | EP |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Id_3", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"},
{"name": "At_1", "type": "String", "role": "Attribute"}
]
}
]
}