← 返回题库
中级

实现楼宇受众价值评分

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    bld_csv = open_url(____).read()
    buildings = pd.read_csv(StringIO(____))
    TYPE_SCORE = {'____':____,'____':____,'____':____,'____':____,'____':____}
    def score(____):
        base = TYPE_SCORE.get(____)
        m = ____ if traffic>=____ else ____ if traffic>=____ else ____ if traffic>=____ else ____
        return round(____)
    buildings = buildings.copy()
    buildings['____'] = buildings.apply(lambda r: score(____), axis=____)
    top5 = buildings.nlargest(____, '____')
    print(____)
    for _, row in top5.iterrows():
        print("____"+row['____']+"____"+row['____']+"____"+row['____']+"____"+str(____))
    print("____"+str(dict(buildings.groupby(____)['____'].mean().round(____))))

示例

输入
solve()
期望输出
Top 5 buildings:
  BLD-002 海淀中心02号 type=commercial score=120.0
  BLD-020 江汉国际20号 type=commercial score=120.0
  BLD-041 朝阳时代41号 type=commercial score=120.0
  BLD-012 海淀中心12号 type=mixed score=102.0
  BLD-017 海淀中心17号 type=mixed score=102.0
Avg by type: {'commercial': np.float64(98.8), 'hospital': np.float64(67.2), 'hotel': np.float64(85.8), 'mixed': np.float64(94.4), 'residential': np.float64(53.5)}
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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