← keep operator page · clause/keep/basic/manual_ex_1
pandas ✅ · DuckDB ✅
keep Me_1, on a data set with the measures Me_1 and Me_2 and the attribute At_1.
Maintaining Components, Example 1, output verbatim: "The operator maintains the specified Components, drops all the other dependent Components of the Data Set (Measures and Attributes) and maintains the independent Components (Identifiers) unchanged."
The three identifiers and Me_1, on the same data points; Me_2 and At_1 are dropped.
DS_r := DS_1 [ keep Me_1 ];
| Id_1 | Id_2 | Id_3 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|---|
| 2010 | A | XX | 20 | 36 | E |
| 2010 | A | YY | 4 | 9 | F |
| 2010 | B | XX | 9 | 10 | F |
{
"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": "Me_2", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "At_1", "type": "String", "role": "Attribute", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| 2010 | A | XX | 20 |
| 2010 | A | YY | 4 |
| 2010 | B | XX | 9 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Id_3", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}