tabulator

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 5 Imported by: 3

README

tabulator

Test GoDoc

Tabulates time/column/value data in a 2 dimensional table.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tabulator

type Tabulator struct {
	Timestamps indexer[time.Time]
	Columns    indexer[string]
	Data       [][]float64
	// contains filtered or unexported fields
}

Tabulator tabulates a set of entries in rows by timestamp and columns by label. For performance reasons, Data must be added sequentially.

func New

func New(columns ...string) *Tabulator

New creates a new Tabulator

func (*Tabulator) Accumulate

func (t *Tabulator) Accumulate()

Accumulate increments the values in each column.

func (*Tabulator) Add

func (t *Tabulator) Add(timestamp time.Time, column string, value float64) bool

Add adds a value for a specified timestamp and column to the table. If there is already a value for that timestamp and column, the specified value is added to the existing value.

Returns false if the column does not exist. Use RegisterColumn to add it first.

func (*Tabulator) Copy

func (t *Tabulator) Copy() *Tabulator

func (*Tabulator) Filter

func (t *Tabulator) Filter(from, to time.Time)

Filter removes all rows that do not fall inside the specified time range. If the specified time is zero, it will be ignored.

func (*Tabulator) GetColumns

func (t *Tabulator) GetColumns() []string

GetColumns returns the (sorted) list of column names.

func (*Tabulator) GetTimestamps

func (t *Tabulator) GetTimestamps() []time.Time

GetTimestamps returns the (sorted) list of timestamps in the table.

func (*Tabulator) GetValues

func (t *Tabulator) GetValues(columnName string) ([]float64, bool)

GetValues returns the value for the specified column for each timestamp in the table. The values are sorted by timestamp.

func (*Tabulator) MarshalJSON added in v0.3.0

func (t *Tabulator) MarshalJSON() ([]byte, error)

func (*Tabulator) RegisterColumn

func (t *Tabulator) RegisterColumn(column ...string)

RegisterColumn adds the specified columns to the table.

func (*Tabulator) SaveBinary added in v0.3.0

func (t *Tabulator) SaveBinary() ([]byte, error)

func (*Tabulator) Set

func (t *Tabulator) Set(timestamp time.Time, column string, value float64) bool

Set sets the value for a specified timestamp and column to the table.

Returns false if the column does not exist. Use RegisterColumn to add it first.

func (*Tabulator) Size

func (t *Tabulator) Size() int

Size returns the number of rows in the table.

func (*Tabulator) UnmarshalJSON added in v0.3.0

func (t *Tabulator) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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