You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Deedle中与pandas dataframe info()等价的功能是什么?

Deedle DataFrame 获取缺失值与类型概览的方法

Deedle没有像pandas的info()那样的一站式内置函数,但可以通过组合其现有API快速生成类似的概览信息:

核心信息获取方式

  • 行数与列数统计:用df.RowCount获取总行数,df.ColumnCount获取总列数。
  • 列级详情统计:遍历DataFrame的列,对每一列:
    • 通过col.Type获取列的推断类型
    • 用col.Values.CountMissing()统计缺失值数量,再用总行数减去缺失值得到非空值数量

示例代码(F#)

open Deedle

// 假设已有DataFrame实例df
printfn "<class 'Deedle.DataFrame'>"
printfn "RowCount: %d entries" df.RowCount
printfn "Data columns (total %d columns):" df.ColumnCount
printfn "#   Column         Non-Null Count  Dtype"
printfn "---  ------         --------------  -----"

df.Columns |> Seq.iteri (fun idx col ->
    let nonNullCount = df.RowCount - col.Values.CountMissing()
    printfn "%-3d %-15s %-16d %s" (idx+1) col.Name nonNullCount (col.Type.ToString())
)

// 可选:统计各类型列的数量
let typeCounts = df.Columns |> Seq.groupBy (fun c -> c.Type) |> Seq.map (fun (t, cs) -> t, cs |> Seq.length)
printfn "\ndtypes: %s" (typeCounts |> Seq.map (fun (t, cnt) -> $"{t.Name}({cnt})") |> String.concat ", ")

输出效果示例

<class 'Deedle.DataFrame'>
RowCount: 30 entries
Data columns (total 9 columns):
#   Column         Non-Null Count  Dtype
---  ------         --------------  -----
1   Name           30              System.String
2   PhoneNumber    30              System.String
3   City           30              System.String
4   Address        30              System.String
5   PostalCode     30              System.String
6   BirthDate      30              System.String
7   Income         26              System.Double
8   CreditLimit    30              System.String
9   MaritalStatus  24              System.String

dtypes: String(8), Double(1)

内容的提问来源于stack exchange,提问作者alkasai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 21:10:28