1 Star 4 Fork 11

王布衣 / pandas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
series_max.go 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-02-16 12:02 . !61#I6CYP6实现通达信LLVBARS函数
package pandas
import "gitee.com/quant1x/pandas/stat"
func (self *NDFrame) Max() any {
values := self.Values()
switch rows := values.(type) {
case []bool:
max := false
i := 0
for idx, iv := range rows {
if iv && !max {
max = iv
i += 1
}
_ = idx
}
if i > 0 {
return max
}
return false
case []string:
max := ""
hasNaN := false
i := 0
for idx, iv := range rows {
if stat.StringIsNaN(iv) {
hasNaN = true
break
}
if iv > max {
max = iv
i += 1
}
_ = idx
}
if hasNaN {
return stat.StringNaN
} else if i > 0 {
return max
}
return stat.StringNaN
case []int64:
max := stat.MinInt64
//i := 0
for idx, iv := range rows {
if stat.Float64IsNaN(float64(iv)) {
continue
}
if iv > max {
max = iv
//i = idx
}
_ = idx
}
return max
case []float32:
max := stat.MinFloat32
hasNan := false
i := 0
for idx, iv := range rows {
if stat.Float32IsNaN(iv) {
hasNan = true
break
}
if iv > max {
max = iv
i += 1
}
_ = idx
}
if hasNan {
return stat.Nil2Float32
} else if i > 0 {
return max
}
return stat.Nil2Float32
//case []float32:
// if self.Len() == 0 {
// return Nil2Float32
// }
// return stat.Max(rows)
case []float64:
max := stat.MinFloat64
hasNaN := false
i := 0
for idx, iv := range rows {
if stat.Float64IsNaN(iv) {
hasNaN = true
break
}
if iv > max {
max = iv
i += 1
}
_ = idx
}
if hasNaN {
return stat.Nil2Float64
} else if i > 0 {
return max
}
return stat.Nil2Float64
//case []float64:
// if self.Len() == 0 {
// return Nil2Float64
// }
// return stat.Max(rows)
default:
panic(ErrUnsupportedType)
}
//return Nil2Float64
}
func (self *NDFrame) ArgMax() int {
return stat.ArgMax2(self.DTypes())
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/quant1x/pandas.git
git@gitee.com:quant1x/pandas.git
quant1x
pandas
pandas
v1.3.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891