中级
统计同分类商家消费对比
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
txs = pd.read_csv(StringIO(open_url(____).read()))
by_mch = txs.groupby(____).agg(total=(____),count=(____),avg=(____)).reset_index()
for cat in ['____','____','____']:
top = by_mch[by_mch['____']==cat].nlargest(____,'____')
print(____)
for _, row in top.iterrows():
print(____)
示例
输入
solve()
期望输出
CAT-01:
西贝莜面村: total=1434.34 count=4 avg=358.58
肯德基: total=972.39 count=4 avg=243.1
必胜客: total=790.48 count=4 avg=197.62
CAT-02:
奈雪的茶: total=1708.92 count=6 avg=284.82
喜茶: total=1645.76 count=6 avg=274.29
瑞幸咖啡: total=1472.48 count=5 avg=294.5
CAT-03:
叮咚买菜: total=747.24 count=3 avg=249.08
沃尔玛: total=656.76 count=3 avg=218.92
手动录入: total=462.85 count=3 avg=154.28
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199