中级
实现传感器历史数据游标分页查询
未完成
中级参考
代码结构已给出,请填写 ____ 处
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 RPI-001/cpu_temp (page_size=10): Page 1: 10 records, last_ts=1748826000.0 Page 2: 10 records, last_ts=1748919600.0 Page 3: 4 records, last_ts=1748934000.0
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199