← 返回题库
中级

实现历史传感器数据游标分页查询

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    readings_csv = open_url(____).read()
    readings = pd.read_csv(StringIO(____))
    PAGE_SIZE = ____
    def cursor_page(____):
        filtered = readings[(____)&(____)].sort_values(____)
        if cursor_ts is not None:
            filtered = filtered[filtered['____'] > cursor_ts]
        page = filtered.head(____)
        next_cursor = float(____) if len(____)==page_size else None
        return page[['____','____','____']].to_dict(____), next_cursor
    did = '____'; metric = '____'
    cursor = None; page_num = ____
    print("____"+did+"____"+metric+"____"+str(____)+"____")
    while True:
        items, next_cursor = cursor_page(____)
        if not items: break
        print("____"+str(____)+"____"+str(len(____))+"____"+str(____))
        if next_cursor is None: break
        cursor = next_cursor; page_num += ____
        if page_num > ____: print(____); break

示例

输入
solve()
期望输出
Cursor pagination SOIL-A01/soil_moisture (page_size=20)
  Page 1: 20 records, last_ts=1748804400.0
  Page 2: 4 records, last_ts=1748818800.0
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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