Documentation ¶
Overview ¶
Package dataframe provides a R-like data frame type that can be easily transferred into R using the rgo package.
This package is still fairly experimental, the API may be broken.
Index ¶
- func IsNumeric(x SimpleData) bool
- type CDataFrame
- func (df *CDataFrame) AppendRow(name string, vals ...SimpleData)
- func (df *CDataFrame) AppendURow(vals ...SimpleData)
- func (df *CDataFrame) Col(colName string) Column
- func (df *CDataFrame) ColIndex(i int) Column
- func (df *CDataFrame) ColNames() []string
- func (df *CDataFrame) FastRowLookups(enable bool)
- func (df *CDataFrame) MarshalJSON() ([]byte, error)
- func (df *CDataFrame) Row(rowName string) Row
- func (df *CDataFrame) RowIndex(i int) Row
- func (df *CDataFrame) RowNames() (rowNames []string, hasNamedRows bool)
- func (df *CDataFrame) SetCols(colNames ...string)
- func (df *CDataFrame) UnmarshalJSON(data []byte) error
- func (df *CDataFrame) ValidateColumns() (err error)
- type Column
- type DataFrame
- type Row
- type SimpleData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNumeric ¶
func IsNumeric(x SimpleData) bool
IsNumeric checks whether x is a numeric type. Currently these consist only of integers and floats. Complex numbers and big numbers are not considered numeric.
Types ¶
type CDataFrame ¶
type CDataFrame struct {
// contains filtered or unexported fields
}
CDataFrame is used to hold tabular data. This type can be easily marshaled into an R dataframe. CDataFrames can only store data that meet the requirements set by SimpleData.
CDataFrames store data by column not by row. As a result, column-oriented operations can be completed with fewer copies than row-oriented ones.
CDataFrames (and associated types) are not thread-safe.
This type is still experimental.
func New ¶
func New(colNames ...string) *CDataFrame
New creates a new DataFrame with the provided column names.
func (*CDataFrame) AppendRow ¶
func (df *CDataFrame) AppendRow(name string, vals ...SimpleData)
AppendRow adds a new row of data to the DataFrame with the given name. If you do not want named rows, use AppendURow instead.
func (*CDataFrame) AppendURow ¶
func (df *CDataFrame) AppendURow(vals ...SimpleData)
AppendURow adds a new row of data to the DataFrame without a name. If you do want named rows, use AppendRow instead.
func (*CDataFrame) Col ¶
func (df *CDataFrame) Col(colName string) Column
Col gets the column of the provided name. This operation does not copy any data.
Col will panic if the colName does not exist.
func (*CDataFrame) ColIndex ¶
func (df *CDataFrame) ColIndex(i int) Column
ColIndex gets the column of the provided index. This operation does not copy any data.
ColIndex will panic if the index is out of bounds.
func (*CDataFrame) ColNames ¶
func (df *CDataFrame) ColNames() []string
ColNames returns a slice of the column names.
func (*CDataFrame) FastRowLookups ¶
func (df *CDataFrame) FastRowLookups(enable bool)
FastRowLookups increases row name book-keeping to increase the performance of row name lookups.
For maximum benefit, enable before adding any rows.
func (*CDataFrame) MarshalJSON ¶
func (df *CDataFrame) MarshalJSON() ([]byte, error)
func (*CDataFrame) Row ¶
func (df *CDataFrame) Row(rowName string) Row
Row gets the row of the provided name. This operation does copy data. Use Col() over Row() whenever possible.
Row will panic if the rowName does not exist.
func (*CDataFrame) RowIndex ¶
func (df *CDataFrame) RowIndex(i int) Row
RowIndex gets the row of the provided index. This operation does copy data. Use ColIndex() over RowIndex() whenever possible.
RowIndex will panic if the index is out of bounds.
func (*CDataFrame) RowNames ¶
func (df *CDataFrame) RowNames() (rowNames []string, hasNamedRows bool)
RowNames returns a slice of the row names and a bool indicating whether the rows are named.
func (*CDataFrame) SetCols ¶
func (df *CDataFrame) SetCols(colNames ...string)
SetCols sets the columns of the DataFrame to have the given names. You may not call this method more than once.
Do not call this method if you are using NewDataFrame.
func (*CDataFrame) UnmarshalJSON ¶
func (df *CDataFrame) UnmarshalJSON(data []byte) error
func (*CDataFrame) ValidateColumns ¶
func (df *CDataFrame) ValidateColumns() (err error)
ValidateColumns checks that columns are composed of identical types.
type Column ¶
type Column interface { json.Marshaler Get(rowName string, x SimpleData) GetIndex(i int, x SimpleData) GetIndexSD(i int) SimpleData GetSD(rowName string) SimpleData Len() int }
Column is an immutable view of a column of a DataFrame. It remains up-to-date even as the values in the DataFrame are changed.
This type is still experimental.
type Row ¶
type Row interface { Get(colName string, x SimpleData) GetIndex(i int, x SimpleData) GetIndexSD(i int) SimpleData GetSD(colName string) SimpleData }
Row is an immutable copy of a row of DataFrame. As it is a copy, it will not reflect changes later made to the DataFrame.
This type is still experimental.
type SimpleData ¶
type SimpleData interface{}
SimpleData is the the data type used for DataFrames. A string, int, float, or bool (of any size) is a valid value for a SimpleData variable.