Documentation ¶
Index ¶
- Constants
- func ClearCache()
- func InitCache(f func() Cache)
- type Cache
- type Comparator
- type Element
- type ElementValue
- type Elements
- type Indexes
- type MapFunction
- type Number
- type RollingSeries
- type RollingWindow
- type Series
- func Bools(values interface{}) Series
- func Err(err error) Series
- func Floats(values interface{}) Series
- func Ints(values interface{}) Series
- func New(values interface{}, t Type, name string) Series
- func NewDefault(defaultValue interface{}, t Type, name string, len int) Series
- func Operation(operate func(index int, eles ...Element) interface{}, seriess ...Series) (Series, error)
- func Strings(values interface{}) Series
- type Type
- type When
- type WhenApplyFunction
- type WhenFilterFunction
- type Wrapper
Constants ¶
const NaN = "NaN"
Variables ¶
This section is empty.
Functions ¶
func ClearCache ¶ added in v0.12.0
func ClearCache()
Types ¶
type Cache ¶ added in v0.12.0
type Cache interface { Set(k string, x interface{}) Get(k string) (interface{}, bool) Clear() DelByKeyPrefix(keyPrefix string) int Size() int }
Cache define series cache
func NewDefaultCache ¶ added in v0.12.0
func NewDefaultCache() Cache
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 ¶ added in v0.8.0
type Element interface { // Setter method Set(interface{}) SetElement(val Element) SetBool(val bool) SetFloat(val float64) SetInt(val int) SetString(val string) // 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 ¶ added in v0.8.0
type ElementValue interface{}
ElementValue represents the value that can be used for marshaling or unmarshaling Elements.
type Elements ¶ added in v0.9.0
type Elements interface { Elem(int) Element Len() int Slice(start, end int) Elements Get(indexs ...int) Elements Append(Elements) Elements Copy() 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 MapFunction ¶ added in v0.10.1
type RollingSeries ¶ added in v0.11.5
type RollingSeries interface { // Max return the biggest element in the rolling series Max() Series // Min return the lowest element in the rolling series Min() Series // Mean calculates the average value of the rolling series Mean() Series // Mean calculates the weighted average value of the rolling series MeanByWeights(weights []float64) Series // Quantile returns the sample of x such that x is greater than or // equal to the fraction p of samples. Quantile(p float64) Series // Median calculates the middle or median value of the rolling series Median() Series // StdDev calculates the standard deviation of the rolling series StdDev() Series // Apply applies a function for the rolling series Apply(f func(window Series, windowIndex int) interface{}, t Type) Series }
RollingSeries defines methods of a rolling series
func NewRollingSeries ¶ added in v0.11.1
func NewRollingSeries(window int, minPeriods int, s Series) RollingSeries
NewRollingSeries establish a rolling Series
type RollingWindow ¶ added in v0.11.1
RollingWindow define rolling window
func NewRollingWindow ¶ added in v0.11.1
func NewRollingWindow(s Series, windowSize int) RollingWindow
type Series ¶
type Series interface { Rolling(window int, minPeriods int) RollingSeries // HasNaN checks whether the Series contain NaN elements. HasNaN() bool // IsNaN returns an array that identifies which of the elements are NaN. IsNaN() []bool // IsNotNaN returns an array that identifies which of the elements are not NaN. IsNotNaN() []bool // 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. Compare(comparator Comparator, comparando interface{}) Series // 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. Float() []float64 // Bool returns the elements of a Series as a []bool or an error if the // transformation is not possible. Bool() ([]bool, error) // Int returns the elements of a Series as a []int or an error if the // transformation is not possible. Int() ([]int, error) // Order returns the indexes for sorting a Series. NaN elements are pushed to the // end by order of appearance. Order(reverse bool) []int // StdDev calculates the standard deviation of a series StdDev() float64 // Mean calculates the average value of a series Mean() float64 // Median calculates the middle or median value, as opposed to // mean, and there is less susceptible to being affected by outliers. Median() float64 // Max return the biggest element in the series Max() float64 // MaxStr return the biggest element in a series of type String MaxStr() string // Min return the lowest element in the series Min() float64 // MinStr return the lowest element in a series of type String MinStr() string // 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 Quantile(p float64) float64 // 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. Map(f MapFunction) Series //Shift series by desired number of periods and returning a new Series object. Shift(periods int) Series // CumProd finds the cumulative product of the first i elements in s and returning a new Series object. CumProd() Series // Prod returns the product of the elements of the Series. Returns 1 if len(s) = 0. Prod() float64 // AddConst adds the scalar c to all of the values in Series and returning a new Series object. AddConst(c float64) Series // AddConst multiply the scalar c to all of the values in Series and returning a new Series object. MulConst(c float64) Series // DivConst Div the scalar c to all of the values in Series and returning a new Series object. DivConst(c float64) Series Add(c Series) Series Sub(c Series) Series Mul(c Series) Series Div(c Series) Series Abs() Series // Sum calculates the sum value of a series Sum() float64 Empty() Series // Returns Error or nil if no error occured Error() error // Subset returns a subset of the series based on the given Indexes. Subset(indexes Indexes) Series // Concat concatenates two series together. It will return a new Series with the // combined elements of both Series. Concat(x Series) Series // Copy will return a copy of the Series. Copy() Series // Records returns the elements of a Series as a []string Records() []string // Type returns the type of a given series Type() Type // Len returns the length of a given Series Len() int // String implements the Stringer interface for Series String() string // Str prints some extra information about a given series Str() string // Val returns the value of a series for the given index. Will panic if the index // is out of bounds. Val(i int) interface{} // Elem returns the element of a series for the given index. Will panic if the // index is out of bounds. // The index could be less than 0. When the index equals -1, Elem returns the last element of a series. Elem(i int) Element // Slice slices Series from start to end-1 index. Slice(start, end int) Series // FillNaN Fill NaN values using the specified value. FillNaN(value ElementValue) // FillNaNForward Fill NaN values using the last non-NaN value FillNaNForward() // FillNaNBackward fill NaN values using the next non-NaN value FillNaNBackward() // CacheAble returns a cacheable series and the returned series's calculation will be cached in case of repeate calcution. // You should make sure that the series will not be modified and has a unique name. CacheAble() Series // Set sets the values on the indexes of a Series and returns the reference // for itself. The original Series is modified. Set(indexes Indexes, newvalues Series) Series // Append adds new elements to the end of the Series. When using Append, the // Series is modified in place. Append(values interface{}) Name() string SetName(name string) SetErr(err error) //And logical operation And(in interface{}) Series //Or logical operation Or(in interface{}) Series //Not logical operation Not() Series //Wrap define special operations for multiple Series Wrap(ss ...Series) Wrapper //When define conditional computation When(whenF WhenFilterFunction) When }
func NewDefault ¶ added in v0.11.1
type Type ¶
type Type string
Type is a convenience alias that can be used for a more type safe way of reason and use Series types.
type When ¶ added in v0.12.0
type When interface { //We do the operation on the elements that satisfy the condition and do nothing on the elements that dose not satisfy the condition. Apply(f WhenApplyFunction) Series }
When defines a conditional computation