2.13 Grouping: logical AND
Perform logical AND operation at aggregation on a sequence made up of boolean values. One task is to find if all students in each class have access to cell phones in online classes based on the following primary school online teaching terminal survey table.
ID | STUDENT_NAME | CLASS | TERMINAL |
---|---|---|---|
1 | Rebecca Moore | Class one | Phone |
2 | Ashley Wilson | Class one | Phone,PC,Pad |
3 | Rachel Johnson | Class one | Phone,PC,Pad |
4 | Emily Smith | Class one | Phone,Pad |
5 | Ashley Smith | Class one | Phone,PC |
6 | Matthew Johnson | Class one | Phone |
7 | Alexis Smith | Class one | Phone,PC |
8 | Megan Wilson | Class one | Phone,PC,Pad |
… | … | … | … |
SPL script:
A | |
---|---|
1 | =T(“survey.xlsx”) |
2 | =A1.group(CLASS;~.(TERMINAL.split@c().pos(“Phone”) > 0).cand():CAND) |
A1 Load data table.
A2 Group the table by class and for each group use cand() function to find if each TERMINAL value contains Phone.
Execution result:
CLASS | CAND |
---|---|
Class one | true |
Class two | true |
Class three | true |
… | … |
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL