1 Star 0 Fork 12

younland/pandas

forked from 王布衣/pandas 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dataframe_group_test.go 675 Bytes
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-04-19 04:55 . !84 #I6W559 实现dataframe分组能力
package pandas
import (
"fmt"
"gitee.com/quant1x/pandas/stat"
"testing"
)
func TestDataFrame_Group(t *testing.T) {
type testStruct struct {
A string
B int
C bool
D float64
}
data := []testStruct{
{"a", 1, true, 0.0},
{"b", 2, false, 0.5},
{"b", 3, false, 3.5},
{"b", 4, false, 2.5},
{"b", 5, false, 1.5},
{"a", 6, true, 0.0},
{"a", 7, true, 0.0},
{"a", 8, true, 0.0},
{"a", 9, true, 0.0},
{"a", 10, true, 0.0},
{"a", 11, true, 0.0},
}
df := LoadStructs(data)
fmt.Println(df)
df1 := df.Group("A", func(kind stat.Type, e any) bool {
v := stat.AnyToString(e)
if v == "b" {
return true
}
return false
})
fmt.Println(df1)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/younland/pandas.git
git@gitee.com:younland/pandas.git
younland
pandas
pandas
master

搜索帮助