dt

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dt provides a simple data processing toolkit.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingData = errors.New("dt: missing data")
)

Errors.

Functions

This section is empty.

Types

type Frame

type Frame struct {
	// contains filtered or unexported fields
}

Frame represents a data frame.

func New

func New(m int, keys ...string) *Frame

New creates a new frame.

func (*Frame) Append

func (a *Frame) Append(record map[string]*Value) *Frame

Append appends a record to the frame.

func (*Frame) Clone

func (a *Frame) Clone(alloc bool, data bool) *Frame

Clone clones the frame.

func (*Frame) Concat

func (a *Frame) Concat(b *Frame) *Frame

Concat concats frame a with b.

func (*Frame) Copy

func (a *Frame) Copy() *Frame

Copy makes a copy of the frame.

func (*Frame) Delete

func (a *Frame) Delete(key string) *Frame

Delete deletes the list by key.

func (*Frame) Describe

func (a *Frame) Describe() *Frame

Describe gives basic summary statistics of the frame.

func (*Frame) DropNA

func (a *Frame) DropNA(keys ...string) *Frame

DropNA drops the NA(nil) values.

func (*Frame) Each

func (a *Frame) Each(f func([]*Value) error, keys ...string) error

Each applies function f on each record of the frame.

func (*Frame) FillNA

func (a *Frame) FillNA(v *Value, keys ...string) *Frame

FillNA fills the NA(nil) with v.

func (*Frame) Filter

func (a *Frame) Filter(f func([]*Value) bool, keys ...string) *Frame

Filter filters the frame with function f.

func (*Frame) Get

func (a *Frame) Get(key string) List

Get gets the list by key.

func (*Frame) GroupBy

func (a *Frame) GroupBy(keys ...string) *Group

GroupBy groups records by keys.

func (*Frame) Has

func (a *Frame) Has(keys ...string) bool

Has checks if the frame has the keys.

func (*Frame) Head

func (a *Frame) Head(k int) *Frame

Head returns the first k records of the frame.

func (*Frame) IGet

func (a *Frame) IGet(i, j int) *Value

IGet gets the value by index.

func (*Frame) ISet

func (a *Frame) ISet(i, j int, value *Value)

ISet sets the value by index.

func (*Frame) Join

func (a *Frame) Join(b *Frame, keys ...string) *Join

Join joins frame a and b.

func (*Frame) Keys

func (a *Frame) Keys() []string

Keys returns the keys of the frame.

func (*Frame) Len

func (a *Frame) Len() int

Len returns the length of frame a.

func (*Frame) Lists

func (a *Frame) Lists() []List

Lists returns the lists of frame a.

func (*Frame) Map

func (a *Frame) Map(f func([]*Value) *Value, keys ...string) List

Map maps the frame to a list by function f.

func (*Frame) MapTo

func (a *Frame) MapTo(key string, f func([]*Value) *Value, keys ...string) *Frame

MapTo maps the frame to a list by function f and set it by key.

func (*Frame) Pick

func (a *Frame) Pick(keys ...string) *Frame

Pick picks some lists and returns a new frame,

func (*Frame) Rename

func (a *Frame) Rename(old, new string) *Frame

Rename renames the key.

func (*Frame) Set

func (a *Frame) Set(key string, list List) *Frame

Set sets the list by key.

func (*Frame) Slice

func (a *Frame) Slice(i, j int) *Frame

Slice returns the slice of frame a.

func (*Frame) Sort

func (a *Frame) Sort(less func([]*Value, []*Value) bool, keys ...string) *Frame

Sort sorts the frame by function less.

func (*Frame) SortBy

func (a *Frame) SortBy(options ...SortOption) *Frame

SortBy sorts the frame by sort options.

func (*Frame) Stack

func (a *Frame) Stack(name string, value string, keys ...string) *Frame

Stack does wide to long reshaping.

func (*Frame) String

func (a *Frame) String() string

String shows frame a as string.

func (*Frame) Swap

func (a *Frame) Swap(i, j int)

Swap swaps the records with indexes i and j.

func (*Frame) Tail

func (a *Frame) Tail(k int) *Frame

Tail returns the last k records of the frame.

func (*Frame) Unstack

func (a *Frame) Unstack(name string, value string, prefix string) *Frame

Unstack does long to wide reshaping.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group represents a group operation.

func (*Group) Apply

func (a *Group) Apply(f func(List) *Value, akey string, key string) *Group

Apply applies the aggregate function to the group.

func (*Group) Do

func (a *Group) Do() *Frame

Do does the group operation.

type Join

type Join struct {
	// contains filtered or unexported fields
}

Join represents a join operation.

func (*Join) Do

func (a *Join) Do(prefix string) *Frame

Do does the join operation.

func (*Join) On

func (a *Join) On(keys ...string) *Join

On sets the left keys.

type List

type List []*Value

List represents a list.

func (List) Copy

func (a List) Copy() List

Copy makes a copy of the list.

func (List) DropNA

func (a List) DropNA() List

DropNA drops the NA(nil) values.

func (List) FillNA

func (a List) FillNA(v *Value) List

FillNA fills NA(nil) values with v.

func (List) Filter

func (a List) Filter(f func(*Value) bool) List

Filter filters the list with function f.

func (List) Map

func (a List) Map(f func(*Value) *Value) List

Map maps list with function f.

type SortOption

type SortOption struct {
	// contains filtered or unexported fields
}

SortOption represents a sort option.

func NAO

func NAO(key string) SortOption

NAO returns a number asc order sort option.

func NDO

func NDO(key string) SortOption

NDO returns a number desc order sort option.

func SAO

func SAO(key string) SortOption

SAO returns a string asc order sort option.

func SDO

func SDO(key string) SortOption

SDO returns a string desc order sort option.

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value represents a value.

func AVG

func AVG(l List) *Value

AVG returns the average of list l.

func COUNT

func COUNT(l List) *Value

COUNT returns the count of list l.

func FIRST

func FIRST(l List) *Value

FIRST returns the first of list l.

func Float

func Float(v float64) *Value

Float creates a Value from float64.

func LAST

func LAST(l List) *Value

LAST returns the last of list l.

func MAX

func MAX(l List) *Value

MAX returns the max of list l.

func MEDIAN

func MEDIAN(l List) *Value

MEDIAN returns the median of list l.

func MIN

func MIN(l List) *Value

MIN returns the min of list l.

func STD

func STD(l List) *Value

STD returns the std of list l.

func SUM

func SUM(l List) *Value

SUM returns the sum of list l.

func String

func String(v string) *Value

String creates a Value from string.

func VAR

func VAR(l List) *Value

VAR returns the var of list l.

func (*Value) Float

func (a *Value) Float() float64

Float returns the value as float64.

func (*Value) String

func (a *Value) String() string

String returns the value as string.

func (*Value) TrimSpace

func (a *Value) TrimSpace() *Value

TrimSpace returns a value with all leading and trailing white space removed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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