← in operator page · comparison/in/comp_set/manual_ex_2
pandas ✅ · DuckDB ✅
Me_1 in { 0, 3, 6, 12 } inside calc, where the new measure Me_2 takes the result.
Element of, Example 2, output verbatim: "The in operator returns true if op belongs to the collection, false otherwise."
Me_2 is true for BS and MO, and false for GZ, SQ, FJ and CQ; Me_1 is kept.
DS_r := DS_1 [ calc Me_2:= Me_1 in { 0, 3, 6, 12 } ];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 2012 | BS | 0 |
| 2012 | GZ | 4 |
| 2012 | SQ | 9 |
| 2012 | MO | 6 |
| 2012 | FJ | 7 |
| 2012 | CQ | 2 |
{
"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": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 2012 | BS | 0 | true |
| 2012 | GZ | 4 | false |
| 2012 | SQ | 9 | false |
| 2012 | MO | 6 | true |
| 2012 | FJ | 7 | false |
| 2012 | CQ | 2 | false |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"},
{"name": "Me_2", "type": "Boolean", "role": "Measure"}
]
}
]
}