feat: Add min and max and try to improve the performance
This commit is contained in:
11
csv.go
11
csv.go
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -21,6 +22,16 @@ func avg(data []float64) float64 {
|
||||
return sum(data) / float64(len(data))
|
||||
}
|
||||
|
||||
func min(data []float64) float64 {
|
||||
sort.Float64s(data)
|
||||
return data[0]
|
||||
}
|
||||
|
||||
func max(data []float64) float64 {
|
||||
sort.Float64s(data)
|
||||
return data[len(data)-1]
|
||||
}
|
||||
|
||||
func csv2float(r io.Reader, column int) ([]float64, error) {
|
||||
cr := csv.NewReader(r)
|
||||
// set this to reuse the same slice for each read
|
||||
|
||||
Reference in New Issue
Block a user