Documentation ¶
Index ¶
- Constants
- type Cache
- type Comparator
- type Element
- type ElementValue
- type Elements
- type FilterFunction
- type FloatValuer
- type Indexes
- type MapFunction
- type Number
- type RollingSeries
- type RollingWindow
- type Self
- 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 ¶
This section is empty.
Types ¶
type Cache ¶ added in v0.12.0
type Cache interface { Set(key string, value interface{}) Get(key string) (interface{}, bool) Clear() Size() int Delete(key string) Copy() Cache State() string }
Cache define series 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 AppendOne(Element) Elements Copy() Elements }
Elements is the interface that represents the array of elements contained on a Series.
type FilterFunction ¶ added in v0.12.1
FilterFunction Select the elements that match the FilterFunction
type FloatValuer ¶ added in v0.12.2
type FloatValuer interface { // Float returns a float64 value. Float() float64 }
FloatValuer is the interface providing the Float method.
Types implementing FloatValuer interface are able to convert themselves to a float Value.
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 quantile of the window of the rolling series. Quantile(p float64) Series // Quantiles can be computed in batches. Quantiles(ps ...float64) []Series // QuantileRolling scrolls to calculate the quantile in the rolling series. // the p's element corresponds to the window of the rolling series one by one. QuantileRolling(p Series) Series // DataQuantile scrolls to calculate the current data's quantile in the rolling series. // the data's element corresponds to the window of the rolling series one by one. DataQuantileRolling(data Series) 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 //Iterate iterates the rolling series, the window series is nil when minPeriods is less than the window size Iterate(f func(window Series, windowIndex int)) }
RollingSeries defines methods of 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 Self ¶ added in v0.12.2
type Self struct {
// contains filtered or unexported fields
}
All the operations on it will influence the Series's content.
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 Quantiles(ps ...float64) []float64 // DataQuantile returns the data quantile in the series DataQuantile(data float64) float64 DataQuantiles(datas ...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 calculation. CacheAble() Series // Immutable returns an immutable series and the series can not be modified. Immutable() 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 //Filter Select the elements that match the FilterFunction Filter(ff FilterFunction) Series // All the operations on Self will influence the Series's content. Self() Self }
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