tables

package
v0.0.0-...-60c38ab Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Package tables implements immutable tables abstraction

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyData

type AnyData interface {
	// IsLazy specifies is it lazy datasource or a table
	IsLazy() bool
	// Use it as lazy datasource
	Lazy() Lazy
	// Use it as a table, if it's really lazy and collect returns an error panic will occur
	Table() *Table
	// Use it as a table, if it's a lazy data source it will be collected to a table
	Collect() (*Table, error)
}

AnyData represents both tables and lazy-streams as common data source type. Any one of them can be used as Table or Lazy stream via this interface. Although, if it's matter, user can decided to use real form of the data by IsLazy selector.

type Batch

type Batch struct {
	lazy.Source
	// contains filtered or unexported fields
}

Batch is batching abstraction to process lazy streams

func (Batch) Flat

func (zf Batch) Flat() Lazy

Flat transforms batching to the normal lazy stream

func (Batch) Reduce

func (zf Batch) Reduce(tf func(t *Table) (fu.Struct, bool, error)) Lazy

Reduce batches to values

func (Batch) Transform

func (zf Batch) Transform(tf func(int) (FeaturesMapper, error)) Batch

Transform transforms streamed data by batches

type Column

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

func Col

func Col(a interface{}) *Column

Col returns Column wrapper over slice

func MatrixColumn

func MatrixColumn(dat []float32, length int) *Column

func (*Column) Bool

func (c *Column) Bool(row int) bool

Bool returns column' value converted to bool

func (*Column) Bools

func (c *Column) Bools() []bool

Bools extracts column' values as []bool

func (*Column) ExtractAs

func (c *Column) ExtractAs(tp reflect.Type, nocopy ...bool) interface{}

ExtractAs extracts values as array with specified type

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").ExtractAs(reflect.TypeOf("")).([]string)[0] -> "32"
t.Col("Rate").ExtractAs(reflect.TypeOf(int(0))).([]int)[0] -> 1

func (*Column) Float

func (c *Column) Float(row int) float64

Float returns column' value converted to float64

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Rate").Float(0) -> 1.2

func (*Column) Floats

func (c *Column) Floats() []float64

Floats extracts column' values as []float64

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Rate").Floats() -> {1.2,1.5}

func (*Column) Index

func (c *Column) Index(i int) fu.Cell

Index returns cell with value at specified index

t := tables.New([]struct{Age int}{{"33"}})
c := t.Col("Age").Index(0)
c.String() -> "33"
c.Float32() -> 33.0
c.TzeInt() -> 33

func (*Column) Inspect

func (c *Column) Inspect() interface{}

Inspect returns raw array of column's values

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Name").Inspect().([]string)[0] -> "Ivanov"
t.Col("Age").Inspect().([]int)[0] -> 32
t.Col("Rate").Inspect().([]float32)[0] -> 1.2

func (*Column) Int

func (c *Column) Int(row int) int

TzeInt returns column' value converted to int

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").TzeInt(0) -> 32
t.Col("Age").Index(0).TzeInt() -> 32

func (*Column) Int16

func (c *Column) Int16(row int) int16

Int16 returns column' value converted to int16

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Int16(0) -> 32
t.Col("Age").Index().Int16() -> 32

func (*Column) Int32

func (c *Column) Int32(row int) int32

Int32 returns column' value converted to int32

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Int32(0) -> 32
t.Col("Age").Index(0).Int32() -> 32

func (*Column) Int64

func (c *Column) Int64(row int) int64

Int64 returns column' value converted to int64

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Int64(0) -> 32
t.Col("Age").Index(0).Int64() -> 32

func (*Column) Int8

func (c *Column) Int8(row int) int8

Int8 returns column' value converted to int8

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Int8(0) -> 32
t.Col("Age").Index().Int8() -> 32

func (*Column) Interface

func (c *Column) Interface(row int) interface{}

Interface returns column' value as is

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Rate").Interface(0).(float32) -> 1.2
t.Col("Rate").Index(0).Interface().(float32) -> 1.2

func (*Column) Ints

func (c *Column) Ints() []int

Ints extracts column' values as []int

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Ints() -> {32,44}

func (*Column) Ints16

func (c *Column) Ints16() []int16

Ints16 extracts column' values as []int16

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Ints16() -> {32,44}

func (*Column) Ints32

func (c *Column) Ints32() []int32

Ints32 extracts column' values as []int32

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Ints32() -> {32,44}

func (*Column) Ints64

func (c *Column) Ints64() []int64

Ints64 extracts column' values as []int64

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Ints64() -> {32,44}

func (*Column) Ints8

func (c *Column) Ints8() []int8

Ints8 extracts column' values as []int8

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Ints8() -> {32,44}

func (*Column) IsFloat

func (c *Column) IsFloat() bool

func (*Column) Len

func (c *Column) Len() int

Len returns length of column

t := tables.New([]struct{Name string}{{"Ivanov"}})
c1 := t.Col("Name")
t.Append([]struct{Name string}{{"Petrov"}})
c2 := t.Col("Name")
c1.Len() -> 1
c2.Len() -> 2

func (*Column) Matrix

func (c *Column) Matrix(docopy ...bool) [][]float32

func (*Column) Max

func (c *Column) Max() fu.Cell

Max returns cell with max column' maximal value

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Max().TzeInt() -> 44
t.Col("Rate").Max().Float32() -> 1.5

func (*Column) MaxIndex

func (c *Column) MaxIndex() int

MaxIndex returns index of first column' maximal value

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").MaxIndex() -> 1

func (*Column) Min

func (c *Column) Min() fu.Cell

Min returns cell with column' minimal value

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Min().TzeInt() -> 32
t.Col("Rate").Min().Float32() -> 1.2

func (*Column) MinIndex

func (c *Column) MinIndex() int

MinIndex returns index of first column' minimal value

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").MinIndex() -> 0

func (*Column) Na

func (c *Column) Na(i int) bool

func (*Column) Raw

func (c *Column) Raw() (reflect.Value, fu.Bits)

Raw returns column internals

func (*Column) Real

func (c *Column) Real(row int) float32

Float32 returns column' value converted to float32

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Rate").Float32(0) -> 1.2

func (*Column) Reals

func (c *Column) Reals() []float32

Reals extracts column' values as []float32

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Rate").Reals() -> {1.2,1.5}

func (*Column) Strings

func (c *Column) Strings() []string

Strings extracts column' values as []string

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Name").Strings() -> {"Ivanov","Petrow"}

func (*Column) Table

func (c *Column) Table(n string) *Table

func (*Column) Tensor

func (c *Column) Tensor(row int) fu.Tensor

Tensor returns column' values as Tensor if it's a Tensor

func (*Column) Text

func (c *Column) Text(row int) string

Text returns column' value converted to string

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Name").Text(0) -> "Ivanov"
t.Col("Name").Index(0).String() -> "Ivanov"

func (*Column) Type

func (c *Column) Type() reflect.Type

Type returns (reflect) type of column' values

func (*Column) Uint

func (c *Column) Uint(row int) uint

Uint returns column' value converted to uint

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uint(0) -> 32

func (*Column) Uint16

func (c *Column) Uint16(row int) uint16

Uint16 returns column' value converted to uint16

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uint16(0) -> 32

func (*Column) Uint32

func (c *Column) Uint32(row int) uint32

Uint32 returns column' value converted to uint32

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uint32(0) -> 32

func (*Column) Uint64

func (c *Column) Uint64(row int) uint64

Uint64 returns column' value converted to uint64

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uint64(0) -> 32
t.Col("Age").Index(0).Uint64() -> 32

func (*Column) Uint8

func (c *Column) Uint8(row int) uint8

Uint8 returns column' value converted to uint8

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uint8(0) -> 32

func (*Column) Uints

func (c *Column) Uints() []uint

Uints extracts column' values as []uint

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uints() -> {32,44}

func (*Column) Uints16

func (c *Column) Uints16() []uint16

Uints16 extracts column' values as []uint16

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uints16() -> {32,44}

func (*Column) Uints32

func (c *Column) Uints32() []uint32

Uints32 extracts column' values as []uint32

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uints32() -> {32,44}

func (*Column) Uints64

func (c *Column) Uints64() []uint64

Uints64 extracts column' values as []uint64

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uints64() -> {32,44}

func (*Column) Uints8

func (c *Column) Uints8() []uint8

Uints8 extracts column' values as []uint8

t := table.New([]struct{Name string; Age int; Rate float}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Col("Age").Uints8() -> {32,44}

func (*Column) Unique

func (c *Column) Unique() *Column

Unique returns column with only unique values

t := tables.New([]struct{Name string}{{"Ivanov"}})
u1 := t.Col("Name").Unique()
t = t.Append([]struct{Name string}{{"Petrov"},{"Petrov"}})
u2 := t.Col("Name").Unique()
u1.Unique().Inspect() -> {}
u2.Unique().Len() -> 2

func (*Column) Value

func (c *Column) Value(i int) reflect.Value

type Enum

type Enum struct {
	Text  string
	Value int
}

Enum encapsulate enumeration abstraction in relation to tables

func (Enum) String

func (e Enum) String() string

Text return enum string representation

type Enumerator

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

Enumerator the object enumerates enums in data stream

func (Enumerator) Convert

func (ce Enumerator) Convert(v string, value *reflect.Value, _, _ int) (na bool, err error)

func (Enumerator) Format

func (ce Enumerator) Format(x reflect.Value, na bool) string

func (Enumerator) Type

func (ce Enumerator) Type() reflect.Type

Type returns the type of column

type Enumset

type Enumset map[string]int

Enumset is a set of values belongs to one enumeration

func (Enumset) Enum

func (e Enumset) Enum() Meta

Enum defines enumerated meta-column with the Enum tipe

func (Enumset) Float32

func (e Enumset) Float32() Meta

Enum defines enumerated meta-column with the float32 type

func (Enumset) Integer

func (e Enumset) Integer() Meta

Enum defines enumerated meta-column with the int type

func (Enumset) Len

func (m Enumset) Len() int

Len returns length of enumset aka count of enum values

func (Enumset) Text

func (e Enumset) Text() Meta

Enum defines enumerated meta-column with the string type

type FeaturesMapper

type FeaturesMapper interface {
	// MapFeature returns new table with all original columns except features
	// adding one new column with prediction/calculation
	MapFeatures(*Table) (*Table, error)
	// Cloase releases all bounded resources
	Close() error
}

FeaturesMapper interface is a features transformation abstraction

type Float32Enumerator

type Float32Enumerator struct{ IntegerEnumerator }

func (Float32Enumerator) Convert

func (ce Float32Enumerator) Convert(v string, value *reflect.Value, _, _ int) (na bool, err error)

func (Float32Enumerator) Type

func (ce Float32Enumerator) Type() reflect.Type

type IntegerEnumerator

type IntegerEnumerator struct {
	Enumerator
	// contains filtered or unexported fields
}

func (IntegerEnumerator) Convert

func (ce IntegerEnumerator) Convert(v string, value *reflect.Value, _, _ int) (bool, error)

func (IntegerEnumerator) Format

func (ce IntegerEnumerator) Format(x reflect.Value, na bool) string

func (IntegerEnumerator) Type

func (ce IntegerEnumerator) Type() reflect.Type

type LambdaMapper

type LambdaMapper func(table *Table) (*Table, error)

func (LambdaMapper) Close

func (LambdaMapper) Close() error

func (LambdaMapper) MapFeatures

func (l LambdaMapper) MapFeatures(t *Table) (*Table, error)

type Lazy

type Lazy lazy.Source

func LazyConcat

func LazyConcat(a ...AnyData) Lazy

func LazyConcatf

func LazyConcatf(f ...func() Lazy) Lazy

func LazyZip

func LazyZip(a ...AnyData) Lazy

func SourceError

func SourceError(err error) Lazy

func (Lazy) Alias

func (zf Lazy) Alias(c string, a string) Lazy

func (Lazy) Batch

func (zf Lazy) Batch(length int) Batch

Batch transforms lazy stream to a batching flow

func (Lazy) BatchReduce

func (zf Lazy) BatchReduce(batch int, tf func(*Table) (fu.Struct, bool, error)) Lazy

func (Lazy) BatchTransform

func (zf Lazy) BatchTransform(batch int, tf func(int) (FeaturesMapper, error)) Lazy

func (Lazy) Chain

func (zf Lazy) Chain(zx Lazy) Lazy

func (Lazy) Collect

func (zf Lazy) Collect() (t *Table, err error)

func (Lazy) Count

func (zf Lazy) Count() (int, error)

func (Lazy) Drain

func (zf Lazy) Drain(sink Sink) (err error)

func (Lazy) False

func (zf Lazy) False(c string) Lazy

func (Lazy) Filter

func (zf Lazy) Filter(f interface{}) Lazy

func (Lazy) First

func (zf Lazy) First(n int) Lazy

func (Lazy) Foreach

func (zf Lazy) Foreach(f func(fu.Struct) error) (err error)

func (Lazy) IfEq

func (zf Lazy) IfEq(c string, v ...interface{}) Lazy

func (Lazy) IfFlag

func (zf Lazy) IfFlag(c string) Lazy

func (Lazy) IfGt

func (zf Lazy) IfGt(c string, v interface{}) Lazy

func (Lazy) IfLt

func (zf Lazy) IfLt(c string, v interface{}) Lazy

func (Lazy) IfNe

func (zf Lazy) IfNe(c string, v interface{}) Lazy

func (Lazy) IfNotFlag

func (zf Lazy) IfNotFlag(c string) Lazy

func (Lazy) IsLazy

func (Lazy) IsLazy() bool

func (Lazy) Kfold

func (zf Lazy) Kfold(seed int, kfold int, k int, name string) Lazy

func (Lazy) Lazy

func (zf Lazy) Lazy() Lazy

func (Lazy) LuckyCollect

func (zf Lazy) LuckyCollect() *Table

func (Lazy) LuckyCount

func (zf Lazy) LuckyCount() int

func (Lazy) LuckyDrain

func (zf Lazy) LuckyDrain(sink Sink)

func (Lazy) LuckyReals

func (zf Lazy) LuckyReals() []float32

func (Lazy) Map

func (zf Lazy) Map(f interface{}) Lazy

func (Lazy) Only

func (zf Lazy) Only(c ...string) Lazy

func (Lazy) Parallel

func (zf Lazy) Parallel(concurrency ...int) Lazy

func (Lazy) Rand

func (zf Lazy) Rand(seed int, prob float64) Lazy

func (Lazy) RandSkip

func (zf Lazy) RandSkip(seed int, prob float64) Lazy

func (Lazy) RandomFlag

func (zf Lazy) RandomFlag(c string, seed int, prob float64) Lazy

func (Lazy) Reals

func (zf Lazy) Reals() ([]float32, error)

func (Lazy) Round

func (zf Lazy) Round(prec int) Lazy

func (Lazy) Table

func (zf Lazy) Table() *Table

func (Lazy) Transform

func (zf Lazy) Transform(f func(fu.Struct) (fu.Struct, bool, error)) Lazy

func (Lazy) True

func (zf Lazy) True(c string) Lazy

func (Lazy) TrueIfEq

func (zf Lazy) TrueIfEq(c string, v interface{}, flag string) Lazy

func (Lazy) TrueIfNe

func (zf Lazy) TrueIfNe(c string, v interface{}, flag string) Lazy

func (Lazy) UnpackTensor

func (zf Lazy) UnpackTensor(c string) Lazy

func (Lazy) Update

func (zf Lazy) Update(f interface{}) Lazy

type Matrix

type Matrix struct {
	Features      []float32
	Labels        []float32
	Width, Length int
	LabelsWidth   int // 0 means no labels defined
}

Matrix the presentation of features and labels as plane []float32 slices

func (Matrix) AsColumn

func (m Matrix) AsColumn() *Column

AsColumn converts raw features representation into Column

func (Matrix) AsLabelColumn

func (m Matrix) AsLabelColumn() *Column

AsLabelColumn converts raw labels representation into Column

func (Matrix) AsTable

func (m Matrix) AsTable(names ...string) *Table

AsTable converts raw features representation into Table

type Meta

type Meta interface {
	Type() reflect.Type
	Convert(string, *reflect.Value, int, int) (bool, error)
	Format(reflect.Value, bool) string
}

type Raw

type Raw struct {
	Names   []string
	Columns []reflect.Value
	Na      []fu.Bits
	Length  int
}

Raw is the row presentation of a table, can be accessed by the Table.Raw method

type Sink

type Sink lazy.Sink

func SinkError

func SinkError(err error) Sink

type Table

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

Table implements column based typed data structure Every values in a column has the same type.

func Concat

func Concat(x ...*Table) *Table

func Empty

func Empty() *Table

Empty creates new empty table

func MakeTable

func MakeTable(names []string, columns []reflect.Value, na []fu.Bits, length int) *Table

MakeTable creates ne non-empty table

func New

func New(o interface{}) *Table

New creates new Table object

  • from empty list of structs or empty struct tables.New([]struct{Name string; Age int; Rate float32}{}) for empty table.

  • from list of structs tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})

  • from map tables.New(map[string]interface{}{"Name":[]string{"Ivanov","Petrov"},"Age":[]int{32,44},"Rate":[]float32{1.2,1.5}})

  • from channel of structs type R struct{Name string; Age int; Rate float32} c := make(chan R) go func(){ c <- R{"Ivanov",32,1.2} c <- R{"Petrov",44,1.5} close(c) }() tables.New(c)

func NewEmpty

func NewEmpty(names []string, types []reflect.Type) *Table

func (*Table) Append

func (t *Table) Append(o interface{}) *Table

Append adds data to table

	t := tables.Empty()

  - from list of structs
	t = t.Append([]struct{Name string; Age int; Rate: float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
  - from map of values
	t = t.Append(map[string]interface{}{"Name":[]string{"Ivanov","Petrov"},"Age":[]int{32,44},"Rate":[]float32{1.2,1.5}})

  - from channel
	type R struct{Name string; Age int; Rate float32}
	c := make(chan R)
	go func(){
		c <- R{"Ivanov",32,1.2}
		c <- R{"Petrov",44,1.5}
		close(c)
	}()
	t.Append(c)

Or inserts empty column

  • by empty list of structs t = t.Append([]struct{Info string}{})
  • by map of values t = t.Append(map[string]interface{}{"Info":[]string{})

func (*Table) Col

func (t *Table) Col(c string) *Column

Col returns Column object for the table' column selected by the name

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",42,1.2},{"Petrov",42,1.5}})
t.Col("Name").String(0) -> "Ivanov"
t.Col("Name").Len() -> 2

func (*Table) ColIfExists

func (t *Table) ColIfExists(c string) (*Column, bool)

func (*Table) Collect

func (t *Table) Collect() (*Table, error)

Collect returns self, because Table is a table it's the tables.AnyData interface implementation

func (*Table) Concat

func (t *Table) Concat(a *Table) *Table

Concat concats two tables into new one

t1 := tables.New(struct{Name string; Age int; Rate float32}{"Ivanov",32,1.2})
t2 := tables.New(struct{Name string; Age int; Rate float32}{"Petrov",44})
q := t1.Concat(t2)
q.Row(0) -> {"Ivanov",32,1.2}
q.Row(1) -> {"Petrov",44,0}

func (*Table) Display

func (t *Table) Display(from, to int) string

func (*Table) DropNa

func (t *Table) DropNa(names ...string) *Table

func (*Table) Except

func (t *Table) Except(column ...string) *Table

func (*Table) Fetch

func (t *Table) Fetch(i int, r interface{})

Fetch fills struct with table' row data

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
r := struct{Name string; Age int}{}
t.Fetch(0,&r)
r.Name -> "Ivanov"
r.Age -> 32

func (*Table) FillNa

func (t *Table) FillNa(r interface{}) *Table

func (*Table) FillRow

func (t *Table) FillRow(i int, tp reflect.Type, p reflect.Value)

FillRow fills row as a struct

func (*Table) FilteredLen

func (t *Table) FilteredLen(f func(int) bool) int

func (*Table) GetRow

func (t *Table) GetRow(i int, tp reflect.Type) reflect.Value

GetRow gets row as a struct wrapped by reflect.Integer

func (*Table) Head

func (t *Table) Head(n int) string

func (*Table) Index

func (t *Table) Index(r int) fu.Struct

func (*Table) IsLazy

func (*Table) IsLazy() bool

IsLazy returns false, because Table is not lazy it's the tables.AnyData interface implementation

func (*Table) Last

func (t *Table) Last(n ...int) fu.Struct

func (*Table) Lazy

func (t *Table) Lazy() Lazy

Lazy returns new lazy stream sourcing from the table it's the tables.AnyData interface implementation

func (*Table) Len

func (t *Table) Len() int

Len returns count of table rows

func (*Table) List

func (t *Table) List(f interface{})

List executes function for every row

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.List(func(r struct{Rate float}, i int){
			fmt.Println(i, r.Rate)
		})

func (*Table) Matrix

func (t *Table) Matrix(features []string, least ...int) (m Matrix, err error)

Matrix returns matrix without labels

func (*Table) MatrixIf

func (t *Table) MatrixIf(features []string, ifName string, ifValue interface{}) (m0, m1 Matrix, err error)

MatrixIf returns two matrices without labels the first one contains samples with column ifName equal ifValue the second one - samples with column ifName not equal ifValue

func (*Table) MatrixWithLabel

func (t *Table) MatrixWithLabel(features []string, label string, least ...int) (m Matrix, err error)

MatrixWithLabel returns matrix with labels

func (*Table) MatrixWithLabelIf

func (t *Table) MatrixWithLabelIf(features []string, label string, ifName string, ifValue interface{}, least ...int) (test, train Matrix, err error)

MatrixWithLabelIf returns two matrices with labels the first one contains samples with column ifName equal ifValue the second one - samples with column ifName not equal ifValue

func (*Table) Names

func (t *Table) Names() []string

Names returns list of column Names

func (*Table) Only

func (t *Table) Only(column ...string) *Table

Only takes specified Columns as new table

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t2 := t.Only("Age","Rate")
t2.Names() -> ["Age", "Rate"]
t2.Row(0) -> {"Age": 32, "Rate": 1.2}

func (*Table) OnlyNames

func (t *Table) OnlyNames(column ...string) []string

func (*Table) Raw

func (t *Table) Raw() Raw

Raw returns raw table structure

func (*Table) Round

func (t *Table) Round(prec int) *Table

func (*Table) Row

func (t *Table) Row(row int) map[string]reflect.Value

Row returns table row as a map of reflect.Integer

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Row(0)["Name"].String() -> "Ivanov"

func (*Table) Set

func (t *Table) Set(c string, value interface{}) *Table

func (*Table) Shuffle

func (t *Table) Shuffle() *Table

func (*Table) Slice

func (t *Table) Slice(slice ...int) *Table

Slice takes a row slice from table

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Slice(0).Row(0) -> {"Ivanov",32,1.2}
t.Slice(1).Row(0) -> {"Petrov",44,1.5}
t.Slice(0,2).Len() -> 2
t.Slice(1,2).Len() -> 1

func (*Table) Sort

func (t *Table) Sort(opt interface{}) *Table

Sort sorts rows by specified Columns and returns new sorted table

t := tables.New([]struct{Name string; Age int; Rate float32}{{"Ivanov",32,1.2},{"Petrov",44,1.5}})
t.Row(0) -> {Name: "Ivanov", "Age": 32, "Rate", 1.2}
q := t.Sort("Name",tables.DESC)
q.Row(0) -> {Name: "Petrov", "Age": 44, "Rate", 1.5}

func (*Table) String

func (t *Table) String() string

func (*Table) Table

func (t *Table) Table() *Table

Table returns self, because Table is a table it's the tables.AnyData interface implementation

func (*Table) Tail

func (t *Table) Tail(n int) string

func (*Table) With

func (t *Table) With(column *Column, name string) *Table

func (*Table) Without

func (t *Table) Without(name string) *Table

type TextEnumerator

type TextEnumerator struct{ Enumerator }

func (TextEnumerator) Convert

func (ce TextEnumerator) Convert(v string, value *reflect.Value, _, _ int) (bool, error)

func (TextEnumerator) Type

func (ce TextEnumerator) Type() reflect.Type

type Xtensor

type Xtensor struct{ T reflect.Type }

func (Xtensor) Convert

func (t Xtensor) Convert(value string, field *reflect.Value, _, _ int) (_ bool, err error)

func (Xtensor) ConvertElm

func (t Xtensor) ConvertElm(value string, field *reflect.Value, index, width int) (err error)

func (Xtensor) Format

func (Xtensor) Format(x reflect.Value, na bool) string

func (*Xtensor) Type

func (t *Xtensor) Type() reflect.Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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