Documentation ¶
Overview ¶
Package gframe provides a 2D data structure.
Index ¶
- func AggCount(name string, field ...string) aggOptFn
- func AggFirst(name string, field ...string) aggOptFn
- func AggMax(name string, field ...string) aggOptFn
- func AggMean(name string, field ...string) aggOptFn
- func AggSum(name string, field ...string) aggOptFn
- func GroupBy(s ...IntOrString) aggGroupFn
- func GroupByFunc(fn func(Row) Row) aggGroupFn
- func GroupByFuncE(fn func(v Row) (Row, error)) aggGroupFn
- func JoinOn(f1, f2 string) func(r1, r2 Row) bool
- func Max[T conv.Numbers](s Series) T
- func Min[T conv.Numbers](s Series) T
- func Reduce[T any](name string, fn func(T, Row) T, ffn ...func(T) any) aggOptFn
- func Sum[T conv.Numbers](s Series) T
- type Field
- type FieldExpr
- type FilterFunc
- type Frame
- func (f Frame) AppendRows(rows ...Row) Frame
- func (f Frame) At(k IntOrString, i int) Field
- func (f Frame) Columns() []string
- func (f Frame) Concat(f2 Frame) Frame
- func (f Frame) Drop(names ...string) Frame
- func (f Frame) DropRows(indexes ...int) Frame
- func (f Frame) Each(fn func(Row) error) error
- func (f Frame) EachI(fn func(int, Row) error) error
- func (f Frame) Err() error
- func (f Frame) Filter(fn FilterFunc) Frame
- func (f Frame) Group(grpfn aggGroupFn, opts ...aggOptFn) Frame
- func (f Frame) GroupBy(cols ...IntOrString) FrameGroupBy
- func (f Frame) GroupByFunc(fn func(row Row) Row) FrameGroupBy
- func (f Frame) GroupByFuncE(fn func(row Row) (Row, error)) FrameGroupBy
- func (f Frame) Head(n ...int) Frame
- func (f Frame) Info() string
- func (f Frame) InnerJoin(df Frame, fn joinOnFunc) Frame
- func (f Frame) Insert(sers ...Series) Frame
- func (f Frame) Iter() etl.Iter
- func (f Frame) LeftJoin(df Frame, fn joinOnFunc) Frame
- func (f Frame) Len() int
- func (f Frame) Map(fn func(Row) Row) Frame
- func (f Frame) Order(lessfn func(r1, r2 Row) bool) Frame
- func (f Frame) OrderBy() FrameOrderBy
- func (f Frame) OuterJoin(df Frame, fn joinOnFunc) Frame
- func (f Frame) Prefix(p string) Frame
- func (f Frame) Print()
- func (f Frame) Rename(o, n string) Frame
- func (f Frame) RightJoin(df Frame, fn joinOnFunc) Frame
- func (f Frame) Row(i int) Row
- func (f Frame) Rows() []Row
- func (f Frame) Select(fields ...IntOrString) Frame
- func (f Frame) SeriesAt(n IntOrString) Series
- func (f Frame) Slice(start, end int) Frame
- func (f Frame) String() string
- func (f Frame) Tail(n ...int) Frame
- type FrameGroupBy
- func (g FrameGroupBy) Count(field string, as ...string) FrameGroupBy
- func (g FrameGroupBy) Custom(opts ...aggOptFn) FrameGroupBy
- func (g FrameGroupBy) Err() error
- func (g FrameGroupBy) First(field string, as ...string) FrameGroupBy
- func (g FrameGroupBy) Frame() Frame
- func (g FrameGroupBy) Max(field string, as ...string) FrameGroupBy
- func (g FrameGroupBy) Mean(field string, as ...string) FrameGroupBy
- func (g FrameGroupBy) Sum(field string, as ...string) FrameGroupBy
- type FrameOrderBy
- type IntOrString
- type IterFrame
- type Row
- type Series
- func (s Series) Append(data ...any) Series
- func (s Series) AsFloat32() []float32
- func (s Series) AsFloat64() []float64
- func (s Series) AsInt() []int
- func (s Series) AsInt32() []int32
- func (s Series) AsInt64() []int64
- func (s Series) AsString() []string
- func (s Series) At(i int) any
- func (s Series) Clone() Series
- func (s Series) Data() any
- func (s Series) Float32(i int) float32
- func (s Series) Float64(i int) float64
- func (s Series) GoString() string
- func (s Series) Int(i int) int
- func (s Series) Int32(i int) int32
- func (s Series) Int64(i int) int64
- func (s Series) Len() int
- func (s Series) MergeAt(i int, s2 Series) Series
- func (s Series) Name() string
- func (s Series) Remove(indexes ...int) Series
- func (s Series) Size() int
- func (s Series) Slice(start, sz int) Series
- func (s Series) String(i int) string
- func (s Series) WithName(name string) Series
- func (s Series) WithValues(i int, data ...any) Series
- type SeriesData
- func (s SeriesData[T]) At(i int) any
- func (s SeriesData[T]) Clone() SeriesProvider
- func (s SeriesData[T]) Data() any
- func (s SeriesData[T]) Len() int
- func (s SeriesData[T]) Remove(indexes ...int) SeriesProvider
- func (s SeriesData[T]) Size() int
- func (s SeriesData[T]) Slice(start, sz int) SeriesProvider
- func (s SeriesData[T]) String() string
- func (s SeriesData[T]) WithValues(off int, vs ...any) SeriesProvider
- type SeriesProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggFirst ¶
AggFirst returns an aggregation option that returns the first occurrence of the group.
func GroupBy ¶
func GroupBy(s ...IntOrString) aggGroupFn
GroupBy returns a group function that uses the selected fields on a row to be used as the group key.
func GroupByFunc ¶
GroupByFunc wrap a function that takes a row and returns a row to be used as the group key.
func GroupByFuncE ¶
GroupByFuncE is a convenience function for grouping a frame by a function.
Types ¶
type FilterFunc ¶
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame contains data series.
func (Frame) AppendRows ¶
AppendRows appends rows to the frame by mapping the row fields into the proper series
func (Frame) Filter ¶
func (f Frame) Filter(fn FilterFunc) Frame
Filter iterates over the dataframe if the fn returns true it will forward the row to the next dataframe
func (Frame) GroupBy ¶
func (f Frame) GroupBy(cols ...IntOrString) FrameGroupBy
GroupBy initiates a groupby operation.
func (Frame) GroupByFunc ¶
func (f Frame) GroupByFunc(fn func(row Row) Row) FrameGroupBy
GroupByFunc initiates a groupby operation by accepting a function that will return a row where all fields are the key.
func (Frame) GroupByFuncE ¶
func (f Frame) GroupByFuncE(fn func(row Row) (Row, error)) FrameGroupBy
GroupByFuncE initiates a groupby operation by accepting a function that will return a row where all fields are the key and an error if any.
func (Frame) Len ¶
Len returns the number of rows in the dataframe i.e: the biggest series in the dataframe
func (Frame) OrderBy ¶
func (f Frame) OrderBy() FrameOrderBy
func (Frame) Print ¶
func (f Frame) Print()
Print prints a markdown formated dataframe using the regular fmt.Println
func (Frame) Select ¶
func (f Frame) Select(fields ...IntOrString) Frame
Select returns a new dataframe with the selected series
func (Frame) SeriesAt ¶
func (f Frame) SeriesAt(n IntOrString) Series
Series returns the series identified by n of the dataframe.
type FrameGroupBy ¶
type FrameGroupBy struct {
// contains filtered or unexported fields
}
FrameGroupBy contains data to perform a groupby operation.
func (FrameGroupBy) Count ¶
func (g FrameGroupBy) Count(field string, as ...string) FrameGroupBy
Count counts the number of occurrences of the specific field.
func (FrameGroupBy) Custom ¶
func (g FrameGroupBy) Custom(opts ...aggOptFn) FrameGroupBy
Custom adds a custom reduce function to the groupby operation.
func (FrameGroupBy) Err ¶
func (g FrameGroupBy) Err() error
Err returns the error of the groupby operation if any.
func (FrameGroupBy) First ¶
func (g FrameGroupBy) First(field string, as ...string) FrameGroupBy
First returns the first value of the specific field in the group.
func (FrameGroupBy) Frame ¶
func (g FrameGroupBy) Frame() Frame
Frame apply transformations and return new frame.
func (FrameGroupBy) Max ¶
func (g FrameGroupBy) Max(field string, as ...string) FrameGroupBy
Max returns the biggest value in the specific field.
func (FrameGroupBy) Mean ¶
func (g FrameGroupBy) Mean(field string, as ...string) FrameGroupBy
Mean returns the avg value of the specific field.
func (FrameGroupBy) Sum ¶
func (g FrameGroupBy) Sum(field string, as ...string) FrameGroupBy
Sum sums the values of the specific field.
type FrameOrderBy ¶
type FrameOrderBy struct {
// contains filtered or unexported fields
}
func (FrameOrderBy) Asc ¶
func (f FrameOrderBy) Asc(fields ...IntOrString) FrameOrderBy
func (FrameOrderBy) Desc ¶
func (f FrameOrderBy) Desc(fields ...IntOrString) FrameOrderBy
func (FrameOrderBy) Frame ¶
func (f FrameOrderBy) Frame() Frame
Farme apply order and return new frame
type IterFrame ¶
type IterFrame struct {
// contains filtered or unexported fields
}
IterFrame creates a frame iterator that will return Row type per iteration
type Series ¶
type Series struct {
// contains filtered or unexported fields
}
Series is a series of data.
func SP ¶
func SP(name string, provider SeriesProvider) Series
SP returns a series based on provider.
func (Series) AsFloat32 ¶
AsFloat32 converts the series to a float32 slice, if the value can't be converted it will be set as the zero value.
func (Series) AsFloat64 ¶
AsFloat64 converts the series to a float64 slice, if the value can't be converted it will be set as the zero value.
func (Series) AsInt ¶
AsInt converts the series to a int slice, if the value can't be converted it will be set as the zero value.
func (Series) AsInt32 ¶
AsInt32 converts the series to a int32 slice, if the value can't be converted it will be set as the zero value.
func (Series) AsInt64 ¶
AsInt64 converts the series to a int64 slice, if the value can't be converted it will be set as the zero value.
func (Series) AsString ¶
AsString converts the series to a string slice, if the value can't be converted it will be set as an empty string.
func (Series) MergeAt ¶
MergeAt returns a new series with the values from s2 merged into s at index i
type SeriesData ¶
type SeriesData[T any] struct { // contains filtered or unexported fields }
SeriesData handles underlying data of a series.
func (SeriesData[T]) Clone ¶
func (s SeriesData[T]) Clone() SeriesProvider
Clone returns a copy of the series data
func (SeriesData[T]) Data ¶
func (s SeriesData[T]) Data() any
Data returns the series data which can be casted to .([]T)
func (SeriesData[T]) Remove ¶
func (s SeriesData[T]) Remove(indexes ...int) SeriesProvider
Remove one or more indexes from the series
func (SeriesData[T]) Size ¶
func (s SeriesData[T]) Size() int
func (SeriesData[T]) Slice ¶
func (s SeriesData[T]) Slice(start, sz int) SeriesProvider
Slice flattens the series and take a subset
func (SeriesData[T]) String ¶
func (s SeriesData[T]) String() string
func (SeriesData[T]) WithValues ¶
func (s SeriesData[T]) WithValues(off int, vs ...any) SeriesProvider
WithValues returns a copy of the series with the values set on the give index.
type SeriesProvider ¶
type SeriesProvider interface { Len() int Data() any At(int) any // New data mem size? Size() int Clone() SeriesProvider WithValues(off int, data ...any) SeriesProvider Remove(indexes ...int) SeriesProvider Slice(start, sz int) SeriesProvider }
SeriesProvider is an interface for the underlying data on the series.