feat: 15 funciones datascience — estadística, DSP e IO de datos
12 funciones puras con implementación real: Standardize, MinMaxScale, Clip, RollingWindow, ZipSlices, GroupBy, Histogram, Pearson, Autocorrelation, FFT (Cooley-Tukey), DetectOutliers, Impute 3 funciones impuras (stubs): LoadCSV, LoadParquet, FetchDataFrame Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package datascience
|
||||
|
||||
import "math"
|
||||
|
||||
// Impute rellena valores NaN usando forward-fill.
|
||||
// Cada NaN se reemplaza con el último valor válido (no NaN) anterior.
|
||||
// Si el primer valor es NaN y no hay valor anterior, se mantiene como NaN.
|
||||
func Impute(data []float64) []float64 {
|
||||
result := make([]float64, len(data))
|
||||
last := math.NaN()
|
||||
for i, v := range data {
|
||||
if !math.IsNaN(v) {
|
||||
last = v
|
||||
}
|
||||
result[i] = last
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user