← 返回题库
中级

实现素材连续失败告警

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    err_csv = open_url(____).read()
    errors = pd.read_csv(StringIO(____))
    CONSEC_FAIL_THRESHOLD = ____
    def check_creative_failures(____):
        crv_errs = errors_df[errors_df['____']==creative_id].sort_values(____)
        if len(____) < CONSEC_FAIL_THRESHOLD: return False, len(____)
        rows = list(____)
        consec = ____; max_consec = ____
        for r in rows:
            consec = ____ if int(____) else consec + ____
            max_consec = max(____)
        return max_consec >= CONSEC_FAIL_THRESHOLD, max_consec
    print("____"+str(____)+"____")
    alert_creatives = []
    for crv_id in errors['____'].unique():
        is_alert, max_c = check_creative_failures(____)
        if is_alert:
            alert_creatives.append(____)
    for a in alert_creatives[:____]:
        print("____"+a['____']+"____"+str(____))
    print("____"+str(len(____)))

示例

输入
solve()
期望输出
Creative failure alerts (threshold=3 consecutive):
Total creative alerts: 0
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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