← 返回题库
中级

综合:学习数据多格式导出

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd, json
    cards=pd.read_csv(StringIO(open_url(____).read()))
    scheds=pd.read_csv(StringIO(open_url(____).read()))
    uid=cards['____'].value_counts().index[____]
    uc=cards[cards['____']==uid].head(____)
    us=scheds[scheds['____']==uid][['____','____','____']].head(____)
    merged=uc.merge(____)
    data=[{'____':r['____'][:____],'____':r['____'][:____],'____':r['____'],'____':r.get(____)} for _,r in merged.iterrows()]
    print(____)
    print(json.dumps({'____':uid,'____':len(____),'____':data[:____]},ensure_ascii=False)[:____]+"____")
    print(____)
    for d in data[:____]: print(____)

示例

输入
solve()
期望输出
[JSON export]
{"user": "USR-0011", "total": 139, "sample": [{"front": "What is the capital of France?", "back": "Paris", "type": "qa", "status": "new"}, {"front": "What is the speed of light?", "back": "299,792,458...
[CSV export]
  What is the capital of France?,qa,new
  What is the speed of light?,qa,review
  Who wrote "Pride and Prejudice"?,qa,learning
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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