← 返回题库
中级

检测设备上报频率异常(死循环)

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    payloads_csv = open_url(____).read()
    payloads = pd.read_csv(StringIO(____))
    MIN_INTERVAL = ____
    def check_freq(____):
        if len(____) < ____: return False, []
        intervals = [received_times[i]-received_times[i-____] for i in range(____,len(____))]
        violations = [round(____) for iv in intervals if iv < MIN_INTERVAL]
        return len(____)>____, violations
    for did, grp in payloads.groupby(____):
        times = sorted(grp['____'].tolist())
        has_issue, violations = check_freq(____)
        if has_issue:
            print("____" + did + "____" + str(len(____)) + "____" + str(min(____)) + "____")
        else:
            print(____)

示例

输入
solve()
期望输出
OK ARD-001: normal frequency
OK ARD-002: normal frequency
OK ARD-999: normal frequency
OK ESP-001: normal frequency
OK GW-001: normal frequency
OK RPI-001: normal frequency
OK RPI-002: normal frequency
OK RPI-003: normal frequency
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码