gonum

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package gonum exports Cosma DataFrames and Series to Gonum matrices and vectors.

All exported functions require numeric columns (int8–int64, uint8–uint64, float32, float64). Non-numeric columns are skipped unless explicitly named in MatrixOptions.Cols, in which case a non-numeric column is an error.

Null handling must be chosen explicitly via NullPolicy. There is no silent behavior: the zero value (NullError) returns an error on the first null cell.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToMatrix

func ToMatrix(df *dataframe.DataFrame, opts MatrixOptions) (*gonummat.Dense, error)

ToMatrix converts numeric columns of df to a *mat.Dense with shape (rows × len(cols)). Column order matches MatrixOptions.Cols (or schema order if Cols is empty). Columns are extracted in schema order for deterministic output.

func ToVector

func ToVector(s *dataframe.Series, opts VectorOptions) (*gonummat.VecDense, error)

ToVector converts a numeric Series to a *mat.VecDense.

Types

type MatrixOptions

type MatrixOptions struct {
	// Cols is the ordered list of column names to include. If empty, all numeric
	// columns are included in schema order.
	Cols []string
	// NullPolicy controls null handling. Defaults to NullError.
	NullPolicy NullPolicy
	// FillValue is used when NullPolicy == NullFill.
	FillValue float64
}

MatrixOptions configures ToMatrix.

type NullPolicy

type NullPolicy int

NullPolicy controls how null cells are handled during conversion.

const (
	NullError NullPolicy = iota // return error on first null cell (default)
	NullDrop                    // drop entire row if any selected column is null
	NullFill                    // replace null cells with FillValue
)

type VectorOptions

type VectorOptions struct {
	NullPolicy NullPolicy
	FillValue  float64
}

VectorOptions configures ToVector.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL