← 返回题库
初级

查询账户余额快照数据

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    from pyodide.http import open_url
    offices_csv = open_url("https://data.zuihe.com/dbd/core/state_09/offices.csv").read()
    staff_csv = open_url("https://data.zuihe.com/dbd/core/state_09/staff.csv").read()
    savings_products_csv = open_url("https://data.zuihe.com/dbd/core/state_09/savings_products.csv").read()
    clients_csv = open_url("https://data.zuihe.com/dbd/core/state_09/clients.csv").read()
    savings_accounts_csv = open_url("https://data.zuihe.com/dbd/core/state_09/savings_accounts.csv").read()
    savings_account_transactions_csv = open_url("https://data.zuihe.com/dbd/core/state_09/savings_account_transactions.csv").read()
    gl_accounts_csv = open_url("https://data.zuihe.com/dbd/core/state_09/gl_accounts.csv").read()
    journal_entries_csv = open_url("https://data.zuihe.com/dbd/core/state_09/journal_entries.csv").read()
    cob_job_logs_csv = open_url("https://data.zuihe.com/dbd/core/state_09/cob_job_logs.csv").read()
    account_balance_snapshots_csv = open_url("https://data.zuihe.com/dbd/core/state_09/account_balance_snapshots.csv").read()
    import sqlite3, pandas as pd
    from io import StringIO
    conn = sqlite3.connect(':memory:')
    pd.read_csv(StringIO(account_balance_snapshots_csv)).to_sql('account_balance_snapshots', conn, index=False, if_exists='replace')
    result = pd.read_sql_query("SELECT account_id, balance, available_balance, status FROM account_balance_snapshots WHERE snapshot_date='2026-10-31' ORDER BY account_id LIMIT 10", conn)
    print(result.to_string(index=False))
    conn.close()

示例

输入
solve()
期望输出
account_id  balance  available_balance status
          1 55016.03           55016.03 ACTIVE
          2 20505.95           20505.95 ACTIVE
          3 80023.10           80023.10 ACTIVE
          4 14800.00           14800.00 ACTIVE
          5 36010.50           36010.50 ACTIVE
          6 14500.00           14500.00 ACTIVE
          7 10000.00           10000.00 ACTIVE
          8 37000.00           37000.00 ACTIVE
          9 12200.00           12200.00 ACTIVE
         10 66018.97           66018.97 ACTIVE
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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