Documentation ¶
Index ¶
- Variables
- type DataFrame
- func (df *DataFrame) AddScalar(scalar float64) *DataFrame
- func (df *DataFrame) AddVec(vec []float64) *DataFrame
- func (df *DataFrame) Append(other *DataFrame) *DataFrame
- func (df *DataFrame) Breakout() Map
- func (df *DataFrame) ColCount() int
- func (df *DataFrame) Copy() *DataFrame
- func (df *DataFrame) Count(lambda func(x float64) bool) *DataFrame
- func (df *DataFrame) Div(other *DataFrame) *DataFrame
- func (df *DataFrame) Drop(val float64) *DataFrame
- func (df *DataFrame) End() time.Time
- func (df *DataFrame) ForEach(lambda func(int, time.Time, map[string]float64) map[string]float64)
- func (df *DataFrame) Frequency(frequency Frequency) *DataFrame
- func (df *DataFrame) IdxMax() *DataFrame
- func (df *DataFrame) Insert(name string, col []float64) *DataFrame
- func (df *DataFrame) InsertMap(date time.Time, vals map[string]float64) *DataFrame
- func (df *DataFrame) InsertRow(date time.Time, vals ...float64) *DataFrame
- func (df *DataFrame) Lag(n int) *DataFrame
- func (df *DataFrame) Last() *DataFrame
- func (df *DataFrame) Len() int
- func (df *DataFrame) Max() *DataFrame
- func (df *DataFrame) Min() *DataFrame
- func (df *DataFrame) Mul(other *DataFrame) *DataFrame
- func (df *DataFrame) MulScalar(scalar float64) *DataFrame
- func (df *DataFrame) RollingSumScaled(ii int, scalar float64) *DataFrame
- func (df *DataFrame) SMA(lookback int) *DataFrame
- func (df *DataFrame) Split(columns ...string) (*DataFrame, *DataFrame)
- func (df *DataFrame) Start() time.Time
- func (df *DataFrame) Table() string
- func (df *DataFrame) Trim(begin, end time.Time) *DataFrame
- type Frequency
- type Map
Constants ¶
This section is empty.
Variables ¶
var (
ErrDateIndexNotAligned = errors.New("date index does not align")
)
Functions ¶
This section is empty.
Types ¶
type DataFrame ¶
DataFrame stores a table of values organized by date the vals array is row major - e.g., VFINX PRIDX 1 4 2 5 3 6
Vals[0][0] = 1 Vals[0][1] = 2
func Mean ¶
Mean calculates the mean of all like columns in the dataframes and returns a new dataframe panics if rows are not equal.
func (*DataFrame) AddScalar ¶
AddScalar adds the scalar value to all columns in dataframe df and returns a new dataframe panics if rows are not equal.
func (*DataFrame) AddVec ¶
AddVec adds the vector to all columns in dataframe and returns a new dataframe panics if rows are not equal.
func (*DataFrame) Append ¶
Append takes the date and values from other and appends them to df. If cols do not align, cols in df that are not in other are filled with NaN. If the start date of other is not greater than df then do nothing
func (*DataFrame) Breakout ¶
Breakout takes a dataframe with multiple columns and returns a map of dataframes, one per column
func (*DataFrame) Count ¶
Count creates a new dataframe with the number of columns where the expression lambda func(float64) bool evaluates to true is placed in the `count` column
func (*DataFrame) Div ¶
Div divides all columns in `df` by the corresponding column in `other` and returns a new dataframe. Panics if rows are not equal.
func (*DataFrame) ForEach ¶
ForEachMap takes a lambda function of prototype func(rowIdx int, rowDate time.Time, vals map[string]float64) map[string]float64 and updates the row with the returned value; if nil is returned then don't update the row, otherwise update row with returned values
func (*DataFrame) Frequency ¶
Frequency returns a data frame filtered to the requested frequency; note this is not an in-place function but creates a copy of the data
func (*DataFrame) IdxMax ¶
IdxMax finds the column with the largest value for each row and stores it in a new dataframe with the column name 'idxmax'
func (*DataFrame) InsertMap ¶
InsertMap adds a new row to the dataframe. Date must be after the last date in the dataframe otherwise panic. all columns must already exist in the dataframe, any additional columns in vals is ignored
func (*DataFrame) InsertRow ¶
InsertRow adds a new row to the dataframe. Date must be after the last date in the dataframe and vals must equal the number of columns. If either of these conditions are not met then panic
func (*DataFrame) Lag ¶
Lag shifts the dataframe by the specified number of rows, replacing shifted values by math.NaN() and returns a new dataframe
func (*DataFrame) Last ¶
Last returns a new dataframe with only the last item of the current dataframe
func (*DataFrame) Mul ¶
Mul multiplies all columns in dataframe df by the corresponding column in dataframe other and returns a new dataframe panics if rows are not equal.
func (*DataFrame) MulScalar ¶
MulScalar multiplies all columns in dataframe df by the scalar and returns a new dataframe panics if rows are not equal.
func (*DataFrame) RollingSumScaled ¶
RollingSumScaled computes ∑ df[ii] * scalar and returns a new dataframe panics if rows are not equal.
func (*DataFrame) SMA ¶
SMA computes the simple moving average of all the columns in df for the specified lookback period. The length of the resulting dataframe equals that of the input with NaNs during the warm-up period. Invalid lookback periods result in a dataframe of all NaN. NOTE: lookback is in terms of date periods. if the dataframe is sampled monthly then SMA is monthly,
func (*DataFrame) Split ¶
Split the dataframe into 2, with columns being in the first dataframe and all remaining columns in the second
type Frequency ¶
type Frequency string
Defines a time period - typically used to filter a dataframe
const ( Daily Frequency = "Daily" WeekBegin Frequency = "WeekBegin" WeekEnd Frequency = "WeekEnd" Weekly Frequency = "WeekEnd" MonthBegin Frequency = "MonthBegin" MonthEnd Frequency = "MonthEnd" Monthly Frequency = "MonthEnd" YearBegin Frequency = "YearBegin" YearEnd Frequency = "YearEnd" Annually Frequency = "YearEnd" )
type Map ¶
func (Map) Align ¶
Align finds the maximum start and minimum end across all dataframes and trims them to match
func (Map) DataFrame ¶
DataFrame converts each item in the map to a column in the dataframe. If dataframes do not align they are trimmed to the max start and min end