Golang数据框架包Goframe - 受Python Pandas启发的数据处理工具
Golang数据框架包Goframe - 受Python Pandas启发的数据处理工具 我的第一个Go包已在Go官方包仓库中正式发布:goframe package - github.com/kishyassin/goframe - Go Packages
GoFrame填补了Go生态系统中的一个独特空白:
虽然Go在后端和数据基础设施领域占据主导地位,但大多数开发者在进行数据操作时仍依赖Python(pandas)。GoFrame为Go带来了类型化、高性能的DataFrame,使得开发者能够构建端到端的Go数据处理管道,而无需切换编程语言。

更多关于Golang数据框架包Goframe - 受Python Pandas启发的数据处理工具的实战教程也可以访问 https://www.itying.com/category-94-b0.html
1 回复
更多关于Golang数据框架包Goframe - 受Python Pandas启发的数据处理工具的实战系列教程也可以访问 https://www.itying.com/category-94-b0.html
GoFrame 包确实为 Go 语言的数据处理领域带来了新的可能性。以下是一个使用 GoFrame 进行基本数据操作的示例:
package main
import (
"fmt"
"github.com/kishyassin/goframe"
)
func main() {
// 创建 DataFrame
df := goframe.NewDataFrame(
goframe.Column{"Name", []string{"Alice", "Bob", "Charlie"}},
goframe.Column{"Age", []int{25, 30, 35}},
goframe.Column{"Score", []float64{85.5, 92.0, 78.5}},
)
// 显示 DataFrame
fmt.Println("原始数据:")
fmt.Println(df)
// 过滤数据
filtered := df.Filter(func(row goframe.Row) bool {
return row.GetInt("Age") > 28
})
fmt.Println("\n年龄大于28的数据:")
fmt.Println(filtered)
// 添加新列
df = df.WithColumn("Grade", []string{"A", "B", "C"})
// 分组聚合
grouped := df.GroupBy("Grade").Agg(map[string]string{
"Score": "mean",
"Age": "max",
})
fmt.Println("\n按等级分组聚合:")
fmt.Println(grouped)
// 数据排序
sorted := df.SortBy([]goframe.SortKey{
{Column: "Score", Ascending: false},
})
fmt.Println("\n按分数降序排序:")
fmt.Println(sorted)
}
这个包提供了类似 pandas 的 API 设计,使得从 Python 迁移到 Go 的数据处理工作变得更加容易。类型安全性和性能优势是 GoFrame 的主要特点。

