中级
实现楼宇受众价值评分
未完成
中级参考
代码结构已给出,请填写 ____ 处
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)}
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199