← 返回题库
中级

按时间戳排序合并多设备事件

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    events_csv = open_url(____).read()
    events = pd.read_csv(StringIO(____))
    sorted_events = events.sort_values(____)
    print(____)
    for _, ev in sorted_events.iterrows():
        print(____)

示例

输入
solve()
期望输出
全局事件时序(按时间排序):
  t=1748563200 DEV004 v1 [DeviceOnline]
  t=1748563200 DEV008 v1 [DeviceOnline]
  t=1748563200 DEV001 v1 [DeviceOnline]
  t=1748563200 DEV006 v1 [DeviceOnline]
  t=1748649600 DEV001 v2 [ThresholdChanged]
  t=1748649600 DEV004 v2 [ThresholdChanged]
  t=1748736000 DEV008 v2 [AlarmTriggered]
  t=1748736000 DEV004 v3 [AlarmTriggered]
  t=1748736060 DEV006 v2 [DeviceOffline]
  t=1748736120 DEV006 v3 [DeviceOnline]
  t=1748736300 DEV004 v4 [DeviceOffline]
  t=1748739600 DEV004 v5 [DeviceOnline]
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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