Filtering Data Points · filter
---
config:
flowchart:
useMaxWidth: false
---
flowchart LR
classDef ok fill:#d4edda,stroke:#28a745,color:#000
classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
O["Filtering Data Points · filter<br/>🟢1"]:::ok
v_basic["DS#91;filter cond#93;"]:::ok
subgraph G_use["Used with"]
direction LR
used__join__inner_join["inner_join ↗<br/><small>used by</small>"]:::ext
used__join__left_join["left_join ↗<br/><small>used by</small>"]:::ext
used__join__full_join["full_join ↗<br/><small>used by</small>"]:::ext
used__join__cross_join["cross_join ↗<br/><small>used by</small>"]:::ext
end
v_basic --- O
O -.- G_use
style G_use fill:#ffffff,stroke:#868e96,stroke-width:1px,stroke-dasharray: 1 4
click v_basic href "#form-basic"
click used__join__inner_join href "../join/inner_join.html" "Inner Join · inner_join"
click used__join__left_join href "../join/left_join.html" "Left Join · left_join"
click used__join__full_join href "../join/full_join.html" "Full Join · full_join"
click used__join__cross_join href "../join/cross_join.html" "Cross Join · cross_join"
Types
Takes boolean, any scalar · Gives any type
Comes from: any operator that returns a value
Goes to: whatever takes its input's type
Forms
DS[filter cond] 🟢 · any scalar, boolean → any type
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
filter Id_1 = 1 and Me_1 < 10: a condition on an identifier and a measure.- Manual:
Filtering Data Points, Example 1, output verbatim: “When the expression is true the Data Point is kept in the result, otherwise it is not kept”.
- Expected:
The three data points with
Id_1= 1 andMe_1below 10, with theirAt_1:(1,A,XX)= 2,(1,A,YY)= 2 and(1,B,YY)= 1.
DS_r := DS_1 [ filter Id_1 = 1 and Me_1 < 10 ];
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | XX | 2 | E |
| 1 | A | YY | 2 | F |
| 1 | B | XX | 20 | F |
| 1 | B | YY | 1 | F |
| 2 | A | XX | 4 | E |
| 2 | A | YY | 9 | F |
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | XX | 2 | E |
| 1 | A | YY | 2 | F |
| 1 | B | YY | 1 | F |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Null condition filtered out 🟢 pandas ✅ · DuckDB ✅
- Tests:
filter Me_1 > 10, whereMe_1is null on one data point, so the condition is null there.- Manual:
Filtering Data Points: “it filters out the Data Points of the operand Data Set for which filterCondition condition evaluates to false or null”.
- Expected:
Id_1= 3 and 4 (15 and 20) are kept;Id_1= 1 (5, false) andId_1= 2 (null) are filtered out.
DS_r := DS_1 [ filter Me_1 > 10 ];
| Id_1 | Me_1 |
|---|---|
| 1 | 5 |
| 2 | |
| 3 | 15 |
| 4 | 20 |
| Id_1 | Me_1 |
|---|---|
| 3 | 15 |
| 4 | 20 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗