Resolve Sensor Threshold Checks
Problem
A monitoring system stores named numeric readings and a list of comparison checks between two of those readings.
DataFrame `gauges` (from `gauges.csv`) has columns `tag` (a short label) and `reading` (the gauge's current numeric value).
DataFrame `checks` (from `checks.csv`) has columns `lhs`, `comparator`, `rhs`. `lhs` and `rhs` are gauge tags; `comparator` is one of `'>'`, `'<'`, or `'='`. Each row asks whether the comparison `lhs comparator rhs` holds.
For every check, return its three columns plus a `verdict` column equal to the string `pass` when the comparison is true and `fail` otherwise.
Input data
Example rows — the live problem includes the full dataset.
| tag | reading |
|---|---|
| aa | 66 |
| bb | 77 |
| lhs | comparator | rhs |
|---|---|---|
| aa | > | bb |
| aa | < | bb |
| aa | = | bb |
| bb | > | aa |
| bb | < | aa |
Expected output
Your answer should return 6 rows with the columns lhs, comparator, rhs, verdict.
Starter code (Pandas (Python))
import pandas as pd
def resolve_checks(gauges, checks) -> pd.DataFrame:
# Your code here
return gaugesSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock