Documentation
¶
Overview ¶
Package core provides foundational types, interfaces, and patterns used throughout GopherData.
This package defines:
- Core type system (Dtype enum)
- Generic type constraints (NumericType, Comparable)
- Foundational interfaces (Index, Iterator, Aggregator)
- Sentinel errors
- Functional options pattern
- Global constants and defaults
The core package has no dependencies on other GopherData packages and can be imported by all modules to avoid circular dependencies.
Package core provides foundational types, interfaces, and patterns for GopherData.
Index ¶
Constants ¶
const Version = "v1.0.0"
Version is the current version of GopherData.
Variables ¶
var ( // ErrInvalidShape indicates incompatible dimensions or shapes ErrInvalidShape = errors.New("invalid shape") // ErrColumnNotFound indicates a column name was not found in a DataFrame ErrColumnNotFound = errors.New("column not found") // ErrTypeMismatch indicates incompatible types in an operation ErrTypeMismatch = errors.New("type mismatch") // ErrIndexOutOfBounds indicates an index is outside valid range ErrIndexOutOfBounds = errors.New("index out of bounds") // ErrNullValue indicates a null value was encountered where not allowed ErrNullValue = errors.New("null value encountered") // ErrKeyNotFound indicates a key was not found in an index ErrKeyNotFound = errors.New("key not found in index") // ErrEmptyDataFrame indicates an operation on an empty DataFrame ErrEmptyDataFrame = errors.New("empty dataframe") // ErrDuplicateColumn indicates duplicate column names ErrDuplicateColumn = errors.New("duplicate column name") // ErrEmptySeries indicates an operation on an empty Series ErrEmptySeries = errors.New("empty series") // ErrInvalidArgument indicates an invalid argument was provided ErrInvalidArgument = errors.New("invalid argument") )
Sentinel errors for common error conditions.
var DefaultNAValues = []string{
"",
"NA",
"N/A",
"NULL",
"null",
"NaN",
"nan",
"#N/A",
"#NA",
"None",
"none",
"-",
}
DefaultNAValues is the default list of strings treated as null/NA values.
var DefaultWorkers = 0
DefaultWorkers specifies the default number of parallel workers. 0 means use runtime.NumCPU().
Functions ¶
func ApplyOptions ¶
ApplyOptions applies a slice of options to a target. Returns the first error encountered, if any.
Types ¶
type Aggregator ¶
type Aggregator interface {
// Aggregate computes an aggregation over a slice of values
Aggregate(values []any) (any, error)
// Name returns the name of this aggregation function
Name() string
}
Aggregator defines the interface for custom aggregation functions.
type Comparable ¶
type Comparable interface {
comparable
}
Comparable is a constraint for comparable types.
type Dtype ¶
type Dtype int
Dtype represents the data type of a Series or DataFrame column.
const ( // DtypeInt64 represents 64-bit signed integers DtypeInt64 Dtype = iota // DtypeFloat64 represents 64-bit floating point numbers DtypeFloat64 // DtypeString represents UTF-8 strings DtypeString // DtypeBool represents boolean values DtypeBool // DtypeTime represents datetime values (Phase 2) DtypeTime // DtypeCategory represents categorical/enum values (Phase 3) DtypeCategory )
type Index ¶
type Index interface {
// Len returns the number of elements in the index
Len() int
// Get returns the label at the given position
Get(pos int) any
// Slice returns a subset of the index from start to end (exclusive)
Slice(start, end int) Index
// Loc returns the integer positions for the given labels
Loc(labels ...any) ([]int, error)
// Copy returns a deep copy of the index
Copy() Index
}
Index provides row labels and fast label-based lookups. The interface is defined here in core to avoid circular dependencies. Implementations (RangeIndex, DatetimeIndex, StringIndex) are in dataframe/indexing.go.
type Iterator ¶
type Iterator[T any] interface { // Next advances the iterator and returns true if a value is available Next() bool // Value returns the current value Value() T // Error returns any error that occurred during iteration Error() error }
Iterator provides a generic iterator interface for traversing sequences.
type NumericType ¶
type NumericType interface {
int | int8 | int16 | int32 | int64 |
uint | uint8 | uint16 | uint32 | uint64 |
float32 | float64
}
NumericType is a constraint for numeric types.
type Option ¶
Option represents a functional option pattern for configuring types. T is the type being configured.