diff --git a/formula/abs.go b/formula/abs.go new file mode 100644 index 0000000000000000000000000000000000000000..dad45d595c1e66f3fd78f7f367e9cb79ac0bbea7 --- /dev/null +++ b/formula/abs.go @@ -0,0 +1,12 @@ +package formula + +import ( + "gitee.com/quant1x/pandas" + "gitee.com/quant1x/pandas/stat" +) + +func ABS(S pandas.Series) pandas.Series { + s := S.Float() + d := stat.Abs(s) + return pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", d) +} diff --git a/formula/abs_test.go b/formula/abs_test.go new file mode 100644 index 0000000000000000000000000000000000000000..39a05597028eda030848d1291503fae624127abd --- /dev/null +++ b/formula/abs_test.go @@ -0,0 +1,14 @@ +package formula + +import ( + "fmt" + "gitee.com/quant1x/pandas" + "testing" +) + +func TestABS(t *testing.T) { + v1 := []int32{1, -1, 2, -2} + s := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT64, "", v1) + fmt.Println(ABS(s)) + +}