Documentation
¶
Overview ¶
Package index is an internal collection of data structures and methods for constructing and modifying n-level indexes and column headers.
Index ¶
- type ColLevel
- type Columns
- func (col Columns) Copy() Columns
- func (col *Columns) DropLevel(level int) error
- func (col *Columns) InsertLevel(pos int, labels []string, name string) error
- func (col Columns) Len() int
- func (col Columns) MaxNameWidth() int
- func (col Columns) MultiName(column int) []string
- func (col Columns) MultiNames() [][]string
- func (col Columns) Name(column int) string
- func (col Columns) Names() []string
- func (col Columns) NumLevels() int
- func (col *Columns) Refresh()
- func (col *Columns) Subset(colPositions []int)
- func (col *Columns) SubsetLevels(levelPositions []int) error
- type Config
- type Elements
- type Index
- func (idx Index) Aligned() error
- func (idx Index) Copy() Index
- func (idx Index) DataTypes() []options.DataType
- func (idx *Index) DropLevel(level int) error
- func (idx Index) Elements(position int) Elements
- func (idx *Index) InsertLevel(pos int, values interface{}, name string) error
- func (idx Index) Len() int
- func (idx Index) MaxWidths() []int
- func (idx Index) NumLevels() int
- func (idx *Index) Refresh()
- func (idx *Index) Set(row int, level int, val interface{}) error
- func (idx *Index) Subset(rowPositions []int) error
- func (idx *Index) SubsetLevels(levelPositions []int) error
- func (idx *Index) SwapLevels(i, j int) error
- func (idx Index) Unnamed() bool
- type LabelMap
- type Level
- func (lvl *Level) Convert(kind options.DataType) error
- func (lvl Level) Copy() Level
- func (lvl Level) Len() int
- func (lvl *Level) Refresh()
- func (lvl *Level) ToBool()
- func (lvl *Level) ToDateTime()
- func (lvl *Level) ToFloat64()
- func (lvl *Level) ToInt64()
- func (lvl *Level) ToInterface()
- func (lvl *Level) ToString()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColLevel ¶
type ColLevel struct {
Name string
Labels []string
LabelMap LabelMap
DataType options.DataType
IsDefault bool
}
A ColLevel is a single collection of column labels within a Columns collection, plus label mappings and metadata. It is identical to an index Level except for the Labels, which are a simple []interface{} that do not satisfy the values.Values interface.
func NewColLevel ¶
NewColLevel returns a Columns level with updated label map.
func NewDefaultColLevel ¶
NewDefaultColLevel creates a column level with range labels (0, 1, 2, ...n) and optional name.
func (*ColLevel) Duplicate ¶
Duplicate extends the level by itself n times and modifies the level in place.
func (*ColLevel) Refresh ¶
func (lvl *ColLevel) Refresh()
Refresh updates all the label mappings value within a column level.
func (*ColLevel) ResetDefault ¶
func (lvl *ColLevel) ResetDefault()
ResetDefault converts a column level in place to an ordered default range []int{0, 1, 2,...n}. It is analogous to Reindex but for columns.
type Columns ¶
Columns is a collection of column levels, plus name mappings.
func CreateMultiCol ¶
CreateMultiCol returns a MultiCol from [][]string
func NewColumns ¶
NewColumns returns a new Columns collection from a slice of column levels.
func NewColumnsFromConfig ¶
NewColumnsFromConfig returns new Columns with default length n using a config struct.
func NewDefaultColumns ¶
NewDefaultColumns returns a new Columns collection with default range labels (0, 1, 2, ... n).
func (*Columns) DropLevel ¶
DropLevel drops the specified cols level and modifies the DataFrame in place. If there is only one col level remaining, replaces with a new default col level.
func (*Columns) InsertLevel ¶
InsertLevel inserts a level into the cols and modifies the DataFrame in place.
func (Columns) MaxNameWidth ¶
MaxNameWidth returns the number of characters in the column name with the most characters.
func (Columns) MultiNames ¶
MultiNames returns a slice of the names of the column at every level for every column position.
func (Columns) Names ¶
Names returns the name of every column by concatenating the labels across every level.
func (*Columns) Refresh ¶
func (col *Columns) Refresh()
Refresh updates the global name map and the label mappings at every level. Should be called after Series selection or index modification
func (*Columns) Subset ¶
Subset subsets a Columns with all the column levels located at the specified integer positions and modifies the Columns in place.
func (*Columns) SubsetLevels ¶
SubsetLevels modifies the DataFrame in place with only the specified cols levels.
type Config ¶
type Config struct {
Name string
DataType options.DataType
Index interface{}
IndexName string
MultiIndex []interface{}
MultiIndexNames []string
Col []string
ColName string
MultiCol [][]string
MultiColNames []string
Manual bool
}
A Config customizes the construction of an Index or Columns object.
type Elements ¶
Elements refer to all the elements at the same position across all levels of an index.
type Index ¶
An Index is a collection of levels, plus label mappings
func CreateMultiIndex ¶
CreateMultiIndex creates a multiindex from a slice of interface values representing different levels
func New ¶
New receives one or more Levels and returns a new Index. Expects that Levels already have .LabelMap and .Longest set.
func NewDefault ¶
NewDefault creates a new index with one unnamed index level and range labels (0, 1, 2, ...n)
func NewFromConfig ¶
NewFromConfig returns a new Index with default length n using a config struct.
func (*Index) DropLevel ¶
DropLevel drops an index level and modifies the Index in place. If there is only one level, replaces with default index.
func (*Index) InsertLevel ¶
InsertLevel inserts a level into the index and modifies the index in place.
func (*Index) Refresh ¶
func (idx *Index) Refresh()
Refresh updates the global name map and the label mappings at every level. Should be called after index modification
func (*Index) Set ¶
Set sets the value at the specified index row and level to val and modifies the Index in place.
func (*Index) Subset ¶
Subset subsets the index with the labels located at the specified integer positions and modifies the index in place.
func (*Index) SubsetLevels ¶
SubsetLevels subsets the index with only the levels located at specified integer positions and modifies the index in place.
func (*Index) SwapLevels ¶
SwapLevels swaps two levels in the index and modifies the index in place.
type LabelMap ¶
A LabelMap records the position of labels, in the form {label name: [label position(s)]}
type Level ¶
type Level struct {
DataType options.DataType
Labels values.Values
LabelMap LabelMap
Name string
IsDefault bool
}
A Level is a single collection of labels within an index, plus label mappings and metadata
func InterpolatedNewLevel ¶
InterpolatedNewLevel creates an Index Level and interpolates []interface{}
func MustNewLevel ¶
MustNewLevel returns a new level from an interface, but panics on error
func NewDefaultLevel ¶
NewDefaultLevel creates an index level with range labels (0, 1, 2, ...n) and optional name.
func NewLevel ¶
NewLevel creates an Index Level from a Scalar or Slice interface{} but returns an error if interface{} is not supported by factory.
func (*Level) Convert ¶
Convert an index level from one kind to another in place, then refreshes the LabelMap
func (*Level) Refresh ¶
func (lvl *Level) Refresh()
Refresh updates all the label mappings value within a level.
func (*Level) ToDateTime ¶
func (lvl *Level) ToDateTime()
ToDateTime converts an index level to DateTime
func (*Level) ToInterface ¶
func (lvl *Level) ToInterface()
ToInterface converts an index level to Interface