series

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const NaN = "NaN"

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 added in v0.8.0

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

	NA() Element
}

Element is the interface that defines the types of methods to be present for elements of a Series

func NaNElementByType added in v0.11.5

func NaNElementByType(t Type) Element

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
}

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 MapFunction func(ele Element, index int) Element

type Number added in v0.11.1

type Number float64

func (Number) Div added in v0.11.1

func (n Number) Div(s Series) Series

func (Number) Mod added in v0.11.1

func (n Number) Mod(s Series) Series

func (Number) Sub added in v0.11.1

func (n Number) Sub(s Series) Series

type RollingSeries added in v0.11.5

type RollingSeries interface {
	Max() Series
	Min() Series
	Mean() Series
	MeanByWeights(weights []float64) Series
	Quantile(p float64) Series
	Median() Series
	StdDev() Series
	Apply(f func(window Series, windowIndex int) interface{}, t Type) Series
}

func NewRollingSeries added in v0.11.1

func NewRollingSeries(window int, minPeriods int, s Series) RollingSeries

type RollingWindow added in v0.11.1

type RollingWindow interface {
	HasNext() bool
	NextWindow() Series
}

func NewRollingWindow added in v0.11.1

func NewRollingWindow(s Series, windowSize int) RollingWindow

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 Bools

func Bools(values interface{}) Series

Bools is a constructor for a Bool Series

func Floats

func Floats(values interface{}) Series

Floats is a constructor for a Float Series

func Ints

func Ints(values interface{}) Series

Ints is a constructor for an Int Series

func New

func New(values interface{}, t Type, name string) Series

New is the generic Series constructor

func NewDefault added in v0.11.1

func NewDefault(defaultValue interface{}, t Type, name string, len int) Series

func Operation added in v0.11.1

func Operation(operate func(index int, eles ...Element) interface{}, seriess ...Series) (Series, error)

func Strings

func Strings(values interface{}) Series

Strings is a constructor for a String Series

func (Series) Abs added in v0.11.1

func (s Series) Abs() Series

func (Series) Add added in v0.11.1

func (s Series) Add(c Series) Series

func (Series) AddConst added in v0.11.1

func (s Series) AddConst(c float64) Series

AddConst adds the scalar c to all of the values in Series and returning a new Series object.

func (Series) And added in v0.11.1

func (s Series) And(in interface{}) Series

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

func (s Series) Bool() ([]bool, error)

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

func (s Series) Concat(x Series) Series

Concat concatenates two series together. It will return a new Series with the combined elements of both Series.

func (Series) Copy

func (s Series) Copy() Series

Copy will return a copy of the Series.

func (Series) CumProd added in v0.11.1

func (s Series) CumProd() Series

CumProd finds the cumulative product of the first i elements in s and returning a new Series object.

func (Series) Div added in v0.11.1

func (s Series) Div(c Series) Series

func (Series) DivConst added in v0.11.1

func (s Series) DivConst(c float64) Series

DivConst Div the scalar c to all of the values in Series and returning a new Series object.

func (Series) Elem

func (s Series) Elem(i int) Element

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.

func (Series) Empty

func (s Series) Empty() Series

Empty returns an empty Series of the same type

func (*Series) Error added in v0.11.5

func (s *Series) Error() error

Returns Error or nil if no error occured

func (Series) FillNaN added in v0.11.1

func (s Series) FillNaN(value ElementValue)

FillNaN Fill NaN values using the specified value.

func (Series) FillNaNBackward added in v0.11.1

func (s Series) FillNaNBackward()

FillNaNBackward Fill NaN values using the next non-NaN value

func (Series) FillNaNForward added in v0.11.1

func (s Series) FillNaNForward()

FillNaNForward Fill NaN values using the last non-NaN value

func (Series) Float

func (s Series) Float() []float64

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) HasNaN

func (s Series) HasNaN() bool

HasNaN checks whether the Series contain NaN elements.

func (Series) Int

func (s Series) Int() ([]int, error)

Int returns the elements of a Series as a []int or an error if the transformation is not possible.

func (Series) IsNaN added in v0.8.0

func (s Series) IsNaN() []bool

IsNaN returns an array that identifies which of the elements are NaN.

func (Series) IsNotNaN added in v0.11.1

func (s Series) IsNotNaN() []bool

IsNaN returns an array that identifies which of the elements are not NaN.

func (Series) Len

func (s Series) Len() int

Len returns the length of a given Series

func (Series) Map added in v0.10.1

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) Max added in v0.9.0

func (s Series) Max() float64

Max return the biggest element in the series

func (Series) MaxStr added in v0.9.0

func (s Series) MaxStr() string

MaxStr return the biggest element in a series of type String

func (Series) Mean added in v0.9.0

func (s Series) Mean() float64

Mean calculates the average value of a series

func (Series) Median added in v0.10.1

func (s Series) Median() float64

Median calculates the middle or median value, as opposed to mean, and there is less susceptible to being affected by outliers.

func (Series) Min added in v0.9.0

func (s Series) Min() float64

Min return the lowest element in the series

func (Series) MinStr added in v0.9.0

func (s Series) MinStr() string

MinStr return the lowest element in a series of type String

func (Series) Mul added in v0.11.1

func (s Series) Mul(c Series) Series

func (Series) MulConst added in v0.11.1

func (s Series) MulConst(c float64) Series

AddConst multiply the scalar c to all of the values in Series and returning a new Series object.

func (Series) Or added in v0.11.1

func (s Series) Or(in interface{}) Series

func (Series) Order added in v0.8.0

func (s Series) Order(reverse bool) []int

Order returns the indexes for sorting a Series. NaN elements are pushed to the end by order of appearance.

func (Series) Prod added in v0.11.1

func (s Series) Prod() float64

Prod returns the product of the elements of the Series. Returns 1 if len(s) = 0.

func (Series) Quantile added in v0.9.0

func (s Series) Quantile(p float64) float64

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) Records

func (s Series) Records() []string

Records returns the elements of a Series as a []string

func (Series) Rolling added in v0.11.1

func (s Series) Rolling(window int, minPeriods int) RollingSeries

func (Series) Set

func (s Series) Set(indexes Indexes, newvalues Series) Series

Set sets the values on the indexes of a Series and returns the reference for itself. The original Series is modified.

func (Series) Shift added in v0.11.1

func (s Series) Shift(periods int) Series

Shift series by desired number of periods and returning a new Series object.

func (Series) Slice added in v0.11.5

func (s Series) Slice(j, k int) Series

Slice slices Series from j to k-1 index.

func (Series) StdDev added in v0.9.0

func (s Series) StdDev() float64

StdDev calculates the standard deviation of a series

func (Series) Str

func (s Series) Str() string

Str prints some extra information about a given series

func (Series) String

func (s Series) String() string

String implements the Stringer interface for Series

func (Series) Sub added in v0.11.1

func (s Series) Sub(c Series) Series

func (Series) Subset

func (s Series) Subset(indexes Indexes) Series

Subset returns a subset of the series based on the given Indexes.

func (Series) Sum added in v0.11.5

func (s Series) Sum() float64

Sum calculates the sum value of a series

func (Series) Type

func (s Series) Type() Type

Type returns the type of a given series

func (Series) Val

func (s Series) Val(i int) interface{}

Val returns the value of a series for the given index. Will panic if the index is out of bounds.

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.

const (
	String Type = "string"
	Int    Type = "int"
	Float  Type = "float"
	Bool   Type = "bool"
)

Supported Series Types

Jump to

Keyboard shortcuts

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