Documentation
¶
Index ¶
- type Comparator
- type Element
- type ElementValue
- type Elements
- type Indexes
- type IteratorOption
- type MapFunction
- type Number
- type RollingWindow
- type Series
- func Bools(values interface{}) Series
- func Floats(values interface{}) Series
- func Ints(values interface{}) Series
- func Max(name string, ss ...Series) Series
- func Min(name string, ss ...Series) Series
- func New(values interface{}, t Type, name string) Series
- func NewFromIterator(it iterator, name string) Series
- func Strings(values interface{}) Series
- func (s Series) Add(value interface{}, name string) Series
- func (s *Series) Append(values interface{})
- func (s Series) Bool() ([]bool, error)
- func (s Series) Compare(comparator Comparator, comparando interface{}) Series
- func (s Series) Concat(x Series) Series
- func (s Series) Copy() Series
- func (s Series) Div(value interface{}, name string) Series
- func (s Series) Elem(i int) Element
- func (s Series) Empty() Series
- func (s Series) Equal(other Series) bool
- func (s *Series) Error() error
- func (s Series) Float() []float64
- func (s Series) HasNaN() bool
- func (s Series) Int() ([]int, error)
- func (s Series) IsNaN() []bool
- func (s Series) Len() int
- func (s Series) Map(f MapFunction) Series
- func (s Series) Max() float64
- func (s Series) MaxStr() string
- func (s Series) Mean() float64
- func (s Series) Median() float64
- func (s Series) Min() float64
- func (s Series) MinStr() string
- func (s Series) Mul(value interface{}, name string) Series
- func (s Series) NewFill(value interface{}, t Type, name string) Series
- func (s Series) Order(reverse bool) []int
- func (s Series) Quantile(p float64) float64
- func (s Series) Records() []string
- func (s Series) Rolling(window int) RollingWindow
- func (s Series) Set(indexes Indexes, newvalues Series) Series
- func (s Series) Slice(j, k int) Series
- func (s Series) StdDev() float64
- func (s Series) Str() string
- func (s Series) String() string
- func (s Series) Sub(value interface{}, name string) Series
- func (s Series) Subset(indexes Indexes) Series
- func (s Series) Sum() float64
- func (s Series) Type() Type
- func (s Series) Val(i int) interface{}
- func (s Series) ValuesIterator(opts ...IteratorOption) iterator
- type Type
- type ValuesOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
type Comparator string
Comparator is a convenience alias that can be used for a more type safe way of reason and use comparators.
const ( Eq Comparator = "==" // Equal Neq Comparator = "!=" // Non equal Greater Comparator = ">" // Greater than GreaterEq Comparator = ">=" // Greater or equal than Less Comparator = "<" // Lesser than LessEq Comparator = "<=" // Lesser or equal than In Comparator = "in" // Inside CompFunc Comparator = "func" // user-defined comparison function )
Supported Comparators
type Element ¶
type Element interface {
// Setter method
Set(interface{})
// Comparation methods
Eq(Element) bool
Neq(Element) bool
Less(Element) bool
LessEq(Element) bool
Greater(Element) bool
GreaterEq(Element) bool
// Accessor/conversion methods
Copy() Element // FIXME: Returning interface is a recipe for pain
Val() ElementValue // FIXME: Returning interface is a recipe for pain
String() string
Int() (int, error)
Float() float64
Bool() (bool, error)
// Information methods
IsNA() bool
Type() Type
}
Element is the interface that defines the types of methods to be present for elements of a Series
type ElementValue ¶
type ElementValue interface{}
ElementValue represents the value that can be used for marshaling or unmarshaling Elements.
type Elements ¶
Elements is the interface that represents the array of elements contained on a Series.
type Indexes ¶
type Indexes interface{}
Indexes represent the elements that can be used for selecting a subset of elements within a Series. Currently supported are:
int // Matches the given index number []int // Matches all given index numbers []bool // Matches all elements in a Series marked as true Series [Int] // Same as []int Series [Bool] // Same as []bool
type IteratorOption ¶
type IteratorOption func(*ValuesOptions)
func WithOnlyUnique ¶
func WithOnlyUnique(onlyUnique bool) IteratorOption
func WithReverse ¶
func WithReverse(reverse bool) IteratorOption
func WithSkipNaN ¶
func WithSkipNaN(skipNaN bool) IteratorOption
func WithStep ¶
func WithStep(step int) IteratorOption
type MapFunction ¶
type Number ¶
type Number interface {
int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64
}
Number is a constraint that permits any number type
type RollingWindow ¶
type RollingWindow struct {
// contains filtered or unexported fields
}
RollingWindow is used for rolling window calculations.
func (RollingWindow) StdDev ¶
func (r RollingWindow) StdDev() (s Series)
StdDev returns the rolling mean.
type Series ¶
type Series struct {
Name string // The name of the series
// deprecated: use Error() instead
Err error
// contains filtered or unexported fields
}
Series is a data structure designed for operating on arrays of elements that should comply with a certain type structure. They are flexible enough that can be transformed to other Series types and account for missing or non valid elements. Most of the power of Series resides on the ability to compare and subset Series of different types.
func NewFromIterator ¶
func (*Series) Append ¶
func (s *Series) Append(values interface{})
Append adds new elements to the end of the Series. When using Append, the Series is modified in place.
func (Series) Bool ¶
Bool returns the elements of a Series as a []bool or an error if the transformation is not possible.
func (Series) Compare ¶
func (s Series) Compare(comparator Comparator, comparando interface{}) Series
Compare compares the values of a Series with other elements. To do so, the elements with are to be compared are first transformed to a Series of the same type as the caller.
func (Series) Concat ¶
Concat concatenates two series together. It will return a new Series with the combined elements of both Series.
func (Series) Elem ¶
Elem returns the element of a series for the given index. Will panic if the index is out of bounds.
func (Series) Equal ¶
Equal compares two Series for equality. Two Series are considered equal if they have the same name, type, length, and all elements are equal.
func (Series) Float ¶
Float returns the elements of a Series as a []float64. If the elements can not be converted to float64 or contains a NaN returns the float representation of NaN.
func (Series) Int ¶
Int returns the elements of a Series as a []int or an error if the transformation is not possible.
func (Series) Map ¶
func (s Series) Map(f MapFunction) Series
Map applies a function matching MapFunction signature, which itself allowing for a fairly flexible MAP implementation, intended for mapping the function over each element in Series and returning a new Series object. Function must be compatible with the underlying type of data in the Series. In other words it is expected that when working with a Float Series, that the function passed in via argument `f` will not expect another type, but instead expects to handle Element(s) of type Float.
func (Series) Median ¶
Median calculates the middle or median value, as opposed to mean, and there is less susceptible to being affected by outliers.
func (Series) Order ¶
Order returns the indexes for sorting a Series. NaN elements are pushed to the end by order of appearance.
func (Series) Quantile ¶
Quantile returns the sample of x such that x is greater than or equal to the fraction p of samples. Note: gonum/stat panics when called with strings
func (Series) Rolling ¶
func (s Series) Rolling(window int) RollingWindow
Rolling creates new RollingWindow
func (Series) Set ¶
Set sets the values on the indexes of a Series and returns the reference for itself. The original Series is modified.
func (Series) Val ¶
Val returns the value of a series for the given index. Will panic if the index is out of bounds.
func (Series) ValuesIterator ¶
func (s Series) ValuesIterator(opts ...IteratorOption) iterator
ValuesIterator returns an iterator function for the values in the Series.