← 返回题库
中级

实现时序数据TTL过期清理

未完成
中级参考 代码结构已给出,请填写 ____ 处
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(____))
    RAW_TTL = ____ * ____
    AGG_TTL = ____ * ____
    now = readings['____'].max() + ____
    def check_ttl(____):
        ttl = RAW_TTL if data_type=='____' else AGG_TTL
        age = now - uploaded_at
        if age > ttl: return '____', age
        return '____', age
    expired = ____; alive = ____
    for _, row in readings.iterrows():
        status, age = check_ttl(____)
        if status == '____': expired += ____
        else: alive += ____
    print(____)
    print("____" + str(round(____)))
    print("____" + str(____) + "____")
    print("____" + str(____) + "____")
    print("____" + str(____) + "____")

示例

输入
solve()
期望输出
TTL cleanup simulation:
  Now: 1748937600
  Raw data TTL: 7 days
  Alive: 528 records
  Expired: 0 records
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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