frame

package
v0.0.0-...-89480e5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(dst, src Frame) (n int, err error)

func Len

func Len(f Frame) (int, error)

Types

type Frame

type Frame interface {
	Cols() []string

	// TODO io.EOF for y out of range, io.ErrUnexpectedEOF for x out of range?
	Get(x, y int, dst ...interface{}) error
}

A Frame is a two-dimensional data set.

The typical Frame has a small number of named columns and a potentially large number of rows. It is inspired by (and indeed may be implemented by) an SQL table. However, it is possible to have a Frame without column names, and some implementations make large columns as cheap as large rows.

Transforming a frame (slicing, aggregating, arithmetic, etc) is intended to be cheap. In some sense, transformations are lazily evaluated.

As a performance optimization, a Frame may implement any of the following methods to provide implementation-specific versions of the common frame package functions. Users should not use these directly, instead preferring the frame.Fn(f) version for any Fn:

ColumnNames() []string
ColumnType(x int) Type
Permute(cols []int) Frame
Slice(x, xlen, y, ylen int) Frame
Set(x, y int, vals ...interface{}) error
Transpose() Frame
CopyFrom(src Frame) (n int, err error)
CopyTo(dst Frame) (n int, err error)
Accumulate(g Grouping) (Frame, error)
Len() (int, error)

Maybe TODO:

Slice(Rectangle) Frame
Read(dst interface{}, col, off int) error // dst is []T.

func Accumulate

func Accumulate(f Frame, g Grouping) (Frame, error)

func Slice

func Slice(f Frame, x, xlen, y, ylen int) Frame

Slice slices the Frame.

A ylen of -1 means maximize the length. That is, on a 2x2 Frame, Slice(f2x2, 0, 2, 1, -1) produces a 2x1 Frame. This is not intended to be an implementation of Python's negative indexes, it is simply necessary as it can be expensive or impossible to determine the Len of a frame.

func Transpose

func Transpose(f Frame) Frame

type Grouping

type Grouping struct {
	By   []int             // column index to group by, in order
	Func map[int]expr.Expr // column index -> binary operator
}

TODO: consider baking the By field directly into the Frame. Then: x.groupby("Col0", "Col2").fold(sum) could work.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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