← 返回题库
中级

构建设备资产树形JSON输出

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    bld_csv = open_url(____).read()
    loc_csv = open_url(____).read()
    scr_csv = open_url(____).read()
    buildings = pd.read_csv(StringIO(____))
    locations = pd.read_csv(StringIO(____))
    screens = pd.read_csv(StringIO(____))
    tree = {}
    for region, rblds in buildings.groupby(____):
        tree[region] = {'____':len(____),'____':____}
        for _, bld in rblds.iterrows():
            locs = locations[locations['____']==bld['____']]
            for _, loc in locs.iterrows():
                scr_count = len(____)
                tree[region]['____'] += scr_count
    print(____)
    for region, data in tree.items():
        print("____"+str(____)+"____"+str(____)+"____"+str(____)+"____")

示例

输入
solve()
期望输出
Asset tree summary:
  天河: 10 buildings 36 screens
  朝阳: 10 buildings 36 screens
  江汉: 10 buildings 36 screens
  浦东: 10 buildings 36 screens
  海淀: 10 buildings 36 screens
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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