← 返回题库
初级

加载贷款数据并查看基本信息

未完成 100%
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    from pyodide.http import open_url
    from io import StringIO
    loans_raw_csv = open_url("https://data.zuihe.com/dbd/riskctrl/state_00/loans_raw.csv").read()
    import pandas as pd
    from io import StringIO
    df = pd.read_csv(StringIO(loans_raw_csv))
    print(f"行数: {df.shape[0]}, 列数: {df.shape[1]}")
    print(df.head(3).to_string())

示例

输入
solve()
期望输出
行数: 10000, 列数: 47
       id  loanAmnt  term  interestRate  installment grade subGrade  employmentTitle employmentLength  homeOwnership  annualIncome  verificationStatus   issueDate  isDefault  purpose  postCode  regionCode    dti  delinquency_2years  ficoRangeLow  ficoRangeHigh  openAcc  pubRec  pubRecBankruptcies  revolBal  revolUtil  totalAcc  initialListStatus  applicationType earliesCreditLine  title  policyCode   n0   n1   n2   n3   n4    n5    n6   n7    n8   n9   n10  n11  n12  n13  n14
0  212188    4300.0     3         16.99       153.29     D       D3             54.0              NaN              1       86000.0                   1  2014-10-01          1        0     698.0          35   0.95                 0.0         780.0          784.0      3.0     0.0                 0.0    2060.0       17.2      19.0                  0                0          Apr-1970    0.0         1.0  0.0  2.0  2.0  2.0  2.0   3.0   9.0  3.0   6.0  2.0   3.0  0.0  0.0  0.0  3.0
1  299036   28000.0     3          5.32       843.22     A       A1            160.0        10+ years              0      106000.0                   1  2015-10-01          0        0     300.0           9  20.17                 1.0         725.0          729.0     11.0     0.0                 0.0   41321.0       40.9      48.0                  0                0          Mar-1996    0.0         1.0  0.0  2.0  3.0  3.0  4.0   8.0  23.0  8.0  19.0  3.0  11.0  0.0  0.0  0.0  0.0
2  475978   13000.0     3         17.57       467.19     D       D4           6426.0        10+ years              0       39000.0                   2  2015-07-01          0        0      33.0          22  13.05                 0.0         685.0          689.0     18.0     0.0                 0.0    9900.0       70.2      39.0                  0                0          Apr-2004    0.0         1.0  3.0  5.0  6.0  6.0  5.0  10.0  21.0  9.0  15.0  6.0  18.0  0.0  0.0  0.0  5.0
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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