Documentation ¶
Index ¶
- Constants
- Variables
- func GenericSeries[T stat.GenericType](name string, values ...T) stat.Series
- func NewSeries(t stat.Type, name string, vals any) stat.Series
- func NewSeriesWithType(_type stat.Type, name string, values ...any) stat.Series
- func NewSeriesWithoutType(name string, values ...any) stat.Series
- type DataFrame
- func LoadMaps(maps []map[string]interface{}, options ...LoadOption) DataFrame
- func LoadMatrix(mat mat.Matrix) DataFrame
- func LoadRecords(records [][]string, options ...LoadOption) DataFrame
- func LoadStructs(i interface{}, options ...LoadOption) DataFrame
- func NewDataFrame(se ...stat.Series) DataFrame
- func ReadCSV(in any, options ...LoadOption) DataFrame
- func ReadExcel(filename string, options ...LoadOption) DataFrame
- func (self DataFrame) Col(colname string, args ...bool) stat.Series
- func (self DataFrame) ColAsNDArray(colname string) stat.Series
- func (self DataFrame) Concat(dfb DataFrame) DataFrame
- func (self DataFrame) Dims() (int, int)
- func (self DataFrame) Error() error
- func (self DataFrame) FillNa(v any, inplace bool)
- func (self DataFrame) IndexOf(idx int, opt ...any) map[string]any
- func (self DataFrame) Join(series stat.Series) DataFrame
- func (self DataFrame) Names() []string
- func (self DataFrame) Ncol() int
- func (self DataFrame) Nrow() int
- func (self DataFrame) Records() [][]string
- func (self DataFrame) Remove(p stat.ScopeLimit) DataFrame
- func (df DataFrame) Select(indexes SelectIndexes) DataFrame
- func (self DataFrame) SelectRows(p stat.ScopeLimit) DataFrame
- func (self DataFrame) SetName(from string, to string)
- func (self DataFrame) SetNames(colnames ...string) error
- func (self DataFrame) String() (str string)
- func (self DataFrame) Subset(start, end int) DataFrame
- func (self DataFrame) Types() []string
- func (self DataFrame) WriteCSV(out any, options ...WriteOption) error
- func (self DataFrame) WriteExcel(filename string, options ...WriteOption) error
- type LoadOption
- func DefaultType(t stat.Type) LoadOption
- func DetectTypes(b bool) LoadOption
- func HasHeader(b bool) LoadOption
- func NaNValues(nanValues []string) LoadOption
- func Names(names ...string) LoadOption
- func WithComments(b rune) LoadOption
- func WithDelimiter(b rune) LoadOption
- func WithLazyQuotes(b bool) LoadOption
- func WithTypes(coltypes map[string]stat.Type) LoadOption
- type NDFrame
- func (self *NDFrame) Add(x any) stat.Series
- func (self *NDFrame) And(x any) stat.Series
- func (self *NDFrame) Append(values ...any) stat.Series
- func (self *NDFrame) Apply(f func(idx int, v any))
- func (self *NDFrame) Apply2(f func(idx int, v any) any, args ...bool) stat.Series
- func (self *NDFrame) ArgMax() int
- func (self *NDFrame) ArgMin() int
- func (self *NDFrame) Bools() []bool
- func (self *NDFrame) Concat(x stat.Series) stat.Series
- func (self *NDFrame) Copy() stat.Series
- func (self *NDFrame) DTypes() []stat.DType
- func (self *NDFrame) Diff(param any) (s stat.Series)
- func (self *NDFrame) Div(x any) stat.Series
- func (s *NDFrame) EWM(alpha stat.EW) stat.ExponentialMovingWindow
- func (self *NDFrame) Empty(t ...stat.Type) stat.Series
- func (self *NDFrame) Eq(x any) stat.Series
- func (self *NDFrame) FillNa(v any, inplace bool) stat.Series
- func (self *NDFrame) Floats() []float32
- func (self *NDFrame) Gt(x any) stat.Series
- func (self *NDFrame) Gte(x any) stat.Series
- func (self *NDFrame) IndexOf(index int, opt ...any) any
- func (self *NDFrame) Ints() []stat.Int
- func (self *NDFrame) Len() int
- func (self *NDFrame) Less(i, j int) bool
- func (self *NDFrame) Logic(f func(idx int, v any) bool) []bool
- func (self *NDFrame) Lt(x any) stat.Series
- func (self *NDFrame) Lte(x any) stat.Series
- func (self *NDFrame) Max() any
- func (self *NDFrame) Mean() stat.DType
- func (self *NDFrame) Min() any
- func (self *NDFrame) Mul(x any) stat.Series
- func (self *NDFrame) NaN() any
- func (self *NDFrame) Name() string
- func (self *NDFrame) Records() []string
- func (self *NDFrame) Ref(param any) (s stat.Series)
- func (self *NDFrame) Rename(n string)
- func (self *NDFrame) Repeat(x any, repeats int) stat.Series
- func (self *NDFrame) Reverse() stat.Series
- func (self *NDFrame) Rolling(param any) stat.RollingAndExpandingMixin
- func (self *NDFrame) Select(r stat.ScopeLimit) stat.Series
- func (self *NDFrame) Shift(periods int) stat.Series
- func (self *NDFrame) Std() stat.DType
- func (self *NDFrame) StdDev() stat.DType
- func (self *NDFrame) Strings() []string
- func (self *NDFrame) Sub(x any) stat.Series
- func (self *NDFrame) Subset(start, end int, opt ...any) stat.Series
- func (self *NDFrame) Sum() stat.DType
- func (self *NDFrame) Swap(i, j int)
- func (self *NDFrame) Type() stat.Type
- func (self *NDFrame) Values() any
- type SelectIndexes
- type SeriesString
- func (self SeriesString) Append(values ...any) stat.Series
- func (self SeriesString) Apply(f func(idx int, v any))
- func (self SeriesString) Copy() stat.Series
- func (self SeriesString) DTypes() []stat.DType
- func (self SeriesString) Diff(param any) (s stat.Series)
- func (self SeriesString) EWM(alpha stat.EW) stat.ExponentialMovingWindow
- func (self SeriesString) Empty(t ...stat.Type) stat.Series
- func (self SeriesString) FillNa(v any, inplace bool) stat.Series
- func (self SeriesString) Floats() []float32
- func (self SeriesString) Ints() []stat.Int
- func (self SeriesString) Len() int
- func (self SeriesString) Less(i, j int) bool
- func (self SeriesString) Logic(f func(idx int, v any) bool) []bool
- func (self SeriesString) Max() any
- func (self SeriesString) Mean() stat.DType
- func (self SeriesString) Min() any
- func (self SeriesString) NaN() any
- func (self SeriesString) Name() string
- func (self SeriesString) Records() []string
- func (self SeriesString) Ref(param any) (s stat.Series)
- func (self SeriesString) Rename(name string)
- func (self SeriesString) Repeat(x any, repeats int) stat.Series
- func (self SeriesString) Rolling(param any) stat.RollingAndExpandingMixin
- func (self SeriesString) Select(r stat.ScopeLimit) stat.Series
- func (self SeriesString) Shift(periods int) stat.Series
- func (self SeriesString) Std() stat.DType
- func (self SeriesString) StdDev() stat.DType
- func (self SeriesString) Subset(start, end int, opt ...any) stat.Series
- func (self SeriesString) Sum() stat.DType
- func (self SeriesString) Swap(i, j int)
- func (self SeriesString) Type() stat.Type
- func (self SeriesString) Values() any
- type WriteOption
Constants ¶
const ( //MAX_FLOAT32_PRICE = float32(9999.9999) // float32的价最大阀值触发扩展到float64 MAX_FLOAT32_PRICE = float32(0) // float32的价最大阀值触发扩展到float64 )
Variables ¶
var (
ErrUnsupportedType = exception.New(0, "Unsupported type")
)
Functions ¶
func GenericSeries ¶
func GenericSeries[T stat.GenericType](name string, values ...T) stat.Series
GenericSeries 泛型方法, 构造序列, 比其它方式对类型的统一性要求更严格
func NewSeriesWithType ¶ added in v0.6.3
NewSeriesWithType 通过类型创新一个新series
Types ¶
type DataFrame ¶
type DataFrame struct { // deprecated: Use Error() instead Err error // contains filtered or unexported fields }
DataFrame 以gota的DataFrame的方法为主, 兼顾新流程, 避免单元格元素结构化
func LoadMaps ¶ added in v0.6.4
func LoadMaps(maps []map[string]interface{}, options ...LoadOption) DataFrame
LoadMaps creates a new DataFrame based on the given maps. This function assumes that every map on the array represents a row of observations.
func LoadMatrix ¶ added in v0.6.4
LoadMatrix loads the given Matrix as a DataFrame TODO: Add Loadoptions
func LoadRecords ¶
func LoadRecords(records [][]string, options ...LoadOption) DataFrame
LoadRecords creates a new DataFrame based on the given records. 这个方法是从本地缓存文件读取数据的第二步, 数据从形式上只能是字符串
func LoadStructs ¶
func LoadStructs(i interface{}, options ...LoadOption) DataFrame
LoadStructs creates a new DataFrame from arbitrary struct slices.
LoadStructs will ignore unexported fields inside an struct. Note also that unless otherwise specified the column names will correspond with the name of the field.
You can configure each field with the `dataframe:"name[,type]"` struct tag. If the name on the tag is the empty string `""` the field name will be used instead. If the name is `"-"` the field will be ignored.
Examples:
// field will be ignored field int // Field will be ignored Field int `dataframe:"-"` // Field will be parsed with column name Field and type int Field int // Field will be parsed with column name `field_column` and type int. Field int `dataframe:"field_column"` // Field will be parsed with column name `field` and type string. Field int `dataframe:"field,string"` // Field will be parsed with column name `Field` and type string. Field int `dataframe:",string"`
If the struct tags and the given LoadOptions contradict each other, the later will have preference over the former.
func NewDataFrame ¶
NewDataFrame is the generic DataFrame constructor
func ReadCSV ¶
func ReadCSV(in any, options ...LoadOption) DataFrame
ReadCSV reads a CSV file from a io.Reader and builds a DataFrame with the resulting records. 支持文件名和io两种方式读取数据
func ReadExcel ¶ added in v0.6.4
func ReadExcel(filename string, options ...LoadOption) DataFrame
ReadExcel 读取excel文件
func (DataFrame) Col ¶ added in v0.6.3
Col returns a copy of the Series with the given column name contained in the DataFrame. 选取一列
func (DataFrame) ColAsNDArray ¶ added in v0.6.6
func (DataFrame) Remove ¶ added in v0.6.3
func (self DataFrame) Remove(p stat.ScopeLimit) DataFrame
Remove 删除一段范围内的记录
func (DataFrame) Select ¶ added in v0.6.3
func (df DataFrame) Select(indexes SelectIndexes) DataFrame
Select the given DataFrame columns
func (DataFrame) SelectRows ¶ added in v0.6.4
func (self DataFrame) SelectRows(p stat.ScopeLimit) DataFrame
Select 选择一段记录
func (DataFrame) SetNames ¶ added in v0.6.3
SetNames changes the column names of a DataFrame to the ones passed as an argument. 修改全部的列名
func (DataFrame) Subset ¶
Subset returns a subset of the rows of the original DataFrame based on the Series subsetting indexes.
func (DataFrame) WriteCSV ¶
func (self DataFrame) WriteCSV(out any, options ...WriteOption) error
WriteCSV writes the DataFrame to the given io.Writer as a CSV file. 支持文件名和io两种方式写入数据
func (DataFrame) WriteExcel ¶ added in v0.6.4
func (self DataFrame) WriteExcel(filename string, options ...WriteOption) error
WriteExcel 支持文件名和io两种方式写入数据
type LoadOption ¶
type LoadOption func(*loadOptions)
LoadOption is the type used to configure the load of elements
func DefaultType ¶
func DefaultType(t stat.Type) LoadOption
DefaultType sets the defaultType option for loadOptions.
func DetectTypes ¶
func DetectTypes(b bool) LoadOption
DetectTypes sets the detectTypes option for loadOptions.
func HasHeader ¶
func HasHeader(b bool) LoadOption
HasHeader sets the hasHeader option for loadOptions.
func NaNValues ¶
func NaNValues(nanValues []string) LoadOption
NaNValues sets the nanValues option for loadOptions.
func WithComments ¶
func WithComments(b rune) LoadOption
WithComments sets the csv comment line detect to remove lines
func WithDelimiter ¶
func WithDelimiter(b rune) LoadOption
WithDelimiter sets the csv delimiter other than ',', for example '\t'
func WithLazyQuotes ¶
func WithLazyQuotes(b bool) LoadOption
WithLazyQuotes sets csv parsing option to LazyQuotes
type NDFrame ¶
type NDFrame struct {
// contains filtered or unexported fields
}
NDFrame 这里本意是想做一个父类, 实际的效果是一个抽象类
func FillNa ¶ added in v0.6.2
func FillNa[T stat.GenericType](s *NDFrame, v T, inplace bool) *NDFrame
FillNa 填充NaN的元素为v inplace为真是修改series元素的值 如果v和Values()返回值的slice类型不一致就会panic
func NewNDFrame ¶
func NewNDFrame[E stat.GenericType](name string, rows ...E) *NDFrame
func (*NDFrame) Diff ¶ added in v0.6.3
Diff 元素的第一个离散差 First discrete difference of element. Calculates the difference of a {klass} element compared with another element in the {klass} (default is element in previous row).
func (*NDFrame) EWM ¶ added in v0.6.4
func (s *NDFrame) EWM(alpha stat.EW) stat.ExponentialMovingWindow
EWM provides exponential weighted calculations.
func (*NDFrame) Rolling ¶
func (self *NDFrame) Rolling(param any) stat.RollingAndExpandingMixin
Rolling RollingAndExpandingMixin
func (*NDFrame) Select ¶ added in v0.6.3
func (self *NDFrame) Select(r stat.ScopeLimit) stat.Series
Select 选取一段记录
type SelectIndexes ¶ added in v0.6.4
type SelectIndexes interface{}
SelectIndexes are the supported indexes used for the DataFrame.Select method. Currently supported are:
int // Matches the given index number []int // Matches all given index numbers []bool // Matches all columns marked as true string // Matches the column with the matching column name []string // Matches all columns with the matching column names Series [Int] // Same as []int Series [Bool] // Same as []bool Series [String] // Same as []string
type SeriesString ¶
func (SeriesString) Append ¶ added in v0.6.6
func (self SeriesString) Append(values ...any) stat.Series
func (SeriesString) Apply ¶ added in v0.6.6
func (self SeriesString) Apply(f func(idx int, v any))
func (SeriesString) Copy ¶
func (self SeriesString) Copy() stat.Series
func (SeriesString) DTypes ¶ added in v0.6.6
func (self SeriesString) DTypes() []stat.DType
func (SeriesString) EWM ¶ added in v0.6.6
func (self SeriesString) EWM(alpha stat.EW) stat.ExponentialMovingWindow
func (SeriesString) FillNa ¶ added in v0.6.2
func (self SeriesString) FillNa(v any, inplace bool) stat.Series
func (SeriesString) Floats ¶ added in v0.6.6
func (self SeriesString) Floats() []float32
func (SeriesString) Ints ¶ added in v0.6.6
func (self SeriesString) Ints() []stat.Int
func (SeriesString) Len ¶
func (self SeriesString) Len() int
func (SeriesString) Less ¶ added in v0.6.6
func (self SeriesString) Less(i, j int) bool
func (SeriesString) Logic ¶ added in v0.6.6
func (self SeriesString) Logic(f func(idx int, v any) bool) []bool
func (SeriesString) Max ¶ added in v0.6.6
func (self SeriesString) Max() any
func (SeriesString) Mean ¶
func (self SeriesString) Mean() stat.DType
func (SeriesString) Min ¶ added in v0.6.6
func (self SeriesString) Min() any
func (SeriesString) NaN ¶ added in v0.6.6
func (self SeriesString) NaN() any
func (SeriesString) Name ¶
func (self SeriesString) Name() string
func (SeriesString) Records ¶
func (self SeriesString) Records() []string
func (SeriesString) Rename ¶
func (self SeriesString) Rename(name string)
func (SeriesString) Rolling ¶
func (self SeriesString) Rolling(param any) stat.RollingAndExpandingMixin
func (SeriesString) Select ¶ added in v0.6.6
func (self SeriesString) Select(r stat.ScopeLimit) stat.Series
func (SeriesString) Std ¶ added in v0.6.6
func (self SeriesString) Std() stat.DType
func (SeriesString) StdDev ¶
func (self SeriesString) StdDev() stat.DType
func (SeriesString) Subset ¶
func (self SeriesString) Subset(start, end int, opt ...any) stat.Series
func (SeriesString) Sum ¶ added in v0.6.6
func (self SeriesString) Sum() stat.DType
func (SeriesString) Swap ¶ added in v0.6.6
func (self SeriesString) Swap(i, j int)
func (SeriesString) Type ¶
func (self SeriesString) Type() stat.Type
func (SeriesString) Values ¶
func (self SeriesString) Values() any
type WriteOption ¶
type WriteOption func(*writeOptions)
WriteOption is the type used to configure the writing of elements
func WriteHeader ¶
func WriteHeader(b bool) WriteOption
WriteHeader sets the writeHeader option for writeOptions.
Source Files ¶
- dataframe.go
- dataframe_csv.go
- dataframe_excel.go
- dataframe_fillna.go
- dataframe_indexes.go
- dataframe_join.go
- dataframe_map.go
- dataframe_matrix.go
- dataframe_options.go
- dataframe_records.go
- dataframe_remove.go
- dataframe_select.go
- dataframe_struct.go
- dataframe_subset.go
- dataframe_type.go
- dataframe_xstring.go
- series.go
- series_append.go
- series_apply.go
- series_diff.go
- series_ewm.go
- series_fillna.go
- series_generic.go
- series_max.go
- series_min.go
- series_range.go
- series_ref.go
- series_rolling.go
- series_sort.go
- series_sum.go
- series_xstring.go