pandas

package module
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 19 Imported by: 32

README

pandas

Sourcegraph Build Status codecov tag license

1. 介绍

golang版本的pandas

2. 功能/模块划分

2.1 特性列表
模块 一级功能 二级功能 进展情况
dataframe dataframe new [√]
dataframe 类型约束 string [√]
dataframe 类型约束 bool [√]
dataframe 类型约束 int64 [√]
dataframe 类型约束 float64 [√]
dataframe 泛型类型 支持全部的基础类型 [√]
dataframe 泛型类型 自动检测类型 [√] 优先级:string > bool > float > int
dataframe align series长度自动对齐 [√]
dataframe col 选择 [√]
dataframe col 新增1列 [√]
dataframe row 删除多行 [√]
dataframe name 改名, 支持单一列改名 [√]
series series new [√] series的列元素类型和reflect.Kind保持一致
series 伪泛型 构建 [√] 再新建series完成之后类型就确定了
series SeriesBool bool类型 [√]
series SeriesString string类型 [√]
series SeriesInt64 int64类型 [√]
series SeriesFloat64 float64类型 [√]
series rolling 支持序列化参数 [√]

3. 示例

3.1. dataframe
3.2. series

4. 参考的代码:

Documentation

Index

Constants

View Source
const (
	SERIES_TYPE_INVAILD = reflect.Invalid // 无效类型
	SERIES_TYPE_BOOL    = reflect.Bool    // 布尔类型
	SERIES_TYPE_INT32   = reflect.Int32   // int64
	SERIES_TYPE_INT64   = reflect.Int64   // int64
	SERIES_TYPE_FLOAT32 = reflect.Float32 // float32
	SERIES_TYPE_FLOAT64 = reflect.Float64 // float64
	SERIES_TYPE_DTYPE   = SERIES_TYPE_FLOAT64
	SERIES_TYPE_STRING  = reflect.String // string
)

Supported Series Types

View Source
const (
	//MAX_FLOAT32_PRICE = float32(9999.9999) // float32的价最大阀值触发扩展到float64
	MAX_FLOAT32_PRICE = float32(0) // float32的价最大阀值触发扩展到float64
)

Variables

View Source
var (
	ErrUnsupportedType    = errors.New("unsupported type")
	ErrCouldNotDetectType = errors.New("couldn't detect type")
)
View Source
var (
	DefaultTagName = api.DefaultTagName
)

Functions

func ToBool added in v0.6.4

func ToBool(s Series) []bool

func ToFloat32 added in v0.6.4

func ToFloat32(s Series) []float32

ToFloat32 转换Float32

func ToFloat64 added in v0.6.4

func ToFloat64(s Series) []float64

Types

type AlphaType

type AlphaType int
const (
	// AlphaAlpha Specify smoothing factor α directly, 0<α≤1.
	AlphaAlpha AlphaType = iota
	// AlphaCom Specify decay in terms of center of mass, α=1/(1+com), for com ≥ 0.
	AlphaCom
	// AlphaSpan Specify decay in terms of span, α=2/(span+1), for span ≥ 1.
	AlphaSpan
	// AlphaHalfLife Specify decay in terms of half-life, α=1−exp(−ln(2)/halflife), for halflife > 0.
	AlphaHalfLife
)

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.ewm.html

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]any, 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 LoadRecords

func LoadRecords(records [][]string, options ...LoadOption) DataFrame

LoadRecords creates a new DataFrame based on the given records. 这个方法是从本地缓存文件读取数据的第二步, 数据从形式上只能是字符串

func LoadStructs

func LoadStructs(i any, 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

func NewDataFrame(se ...Series) DataFrame

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

func (this DataFrame) Col(colname string, args ...bool) Series

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 (this DataFrame) ColAsNDArray(colname string) Series

func (DataFrame) Concat added in v0.6.16

func (this DataFrame) Concat(dfb DataFrame) DataFrame

func (DataFrame) Dims

func (this DataFrame) Dims() (int, int)

Dims retrieves the dimensions of a DataFrame.

func (DataFrame) Error

func (this DataFrame) Error() error

Returns error or nil if no error occured

func (DataFrame) FillNa added in v0.6.2

func (this DataFrame) FillNa(v any, inplace bool)

FillNa dataframe实现FillNa

func (DataFrame) Filter added in v1.0.5

func (this DataFrame) Filter(columnName string, filter func(kind Type, e any) bool) DataFrame

Filter 过滤

func (DataFrame) Group added in v0.9.15

func (this DataFrame) Group(columnName string, filter func(kind Type, e any) bool) DataFrame

Group 分组

func (DataFrame) IndexOf added in v0.6.18

func (this DataFrame) IndexOf(idx int, opt ...any) map[string]any

IndexOf 取一条记录

idx 为负值时从后往前取

func (DataFrame) Join added in v0.6.3

func (this DataFrame) Join(S ...Series) DataFrame

Join 默认右连接, 加入一个series

func (DataFrame) Names

func (this DataFrame) Names() []string

Names returns the name of the columns on a DataFrame.

func (DataFrame) Ncol

func (this DataFrame) Ncol() int

Ncol returns the number of columns on a DataFrame.

func (DataFrame) Nrow

func (this DataFrame) Nrow() int

Nrow returns the number of rows on a DataFrame.

func (DataFrame) Records

func (this DataFrame) Records(round ...bool) [][]string

Records return the string record representation of a DataFrame.

func (DataFrame) Remove added in v0.6.3

func (this DataFrame) Remove(p api.ScopeLimit) DataFrame

Remove 删除一段范围内的记录

func (DataFrame) Select added in v0.6.3

func (this DataFrame) Select(indexes SelectIndexes) DataFrame

Select the given DataFrame columns

func (DataFrame) SelectRows added in v0.6.4

func (this DataFrame) SelectRows(p api.ScopeLimit) DataFrame

SelectRows 选择一段记录

func (DataFrame) SetName added in v0.6.3

func (this DataFrame) SetName(from string, to string)

SetName 修改一个series的名称

func (DataFrame) SetNames added in v0.6.3

func (this DataFrame) SetNames(colnames ...string) error

SetNames changes the column names of a DataFrame to the ones passed as an argument. 修改全部的列名

func (DataFrame) String

func (this DataFrame) String() (str string)

String implements the Stringer interface for DataFrame

func (DataFrame) Sub added in v0.9.15

func (this DataFrame) Sub(start, end int) DataFrame

Sub 选择一个子集, start end 支持从后到前选择

func (DataFrame) Subset

func (this DataFrame) Subset(start, end int) DataFrame

Subset returns a subset of the rows of the original DataFrame based on the Series subsetting indexes.

func (DataFrame) Types

func (this DataFrame) Types() []string

Types returns the types of the columns on a DataFrame.

func (DataFrame) WriteCSV

func (this 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 (this DataFrame) WriteExcel(filename string, options ...WriteOption) error

WriteExcel 支持文件名和io两种方式写入数据

type EW

type EW struct {
	Com      num.DType // 根据质心指定衰减
	Span     num.DType // 根据跨度指定衰减
	HalfLife num.DType // 根据半衰期指定衰减
	Alpha    num.DType // 直接指定的平滑因子α
	Adjust   bool      // 除以期初的衰减调整系数以核算 相对权重的不平衡(将 EWMA 视为移动平均线)
	IgnoreNA bool      // 计算权重时忽略缺失值
	Callback func(idx int) num.DType
}

EW (Factor) 指数加权(EW)计算Alpha 结构属性非0即为有效启动同名算法

type ExponentialMovingWindow

type ExponentialMovingWindow struct {
	Data     Series    // 序列
	AType    AlphaType // 计算方式: com/span/halflefe/alpha
	Param    num.DType // 参数类型为浮点
	Adjust   bool      // 默认为真, 是否调整, 默认真时, 计算序列的EW移动平均线, 为假时, 计算指数加权递归
	IgnoreNA bool      // 默认为假, 计算权重时是否忽略缺失值NaN

	Cb func(idx int) num.DType
	// contains filtered or unexported fields
}

ExponentialMovingWindow 加权移动窗口

func (ExponentialMovingWindow) Mean

type LoadOption

type LoadOption func(*loadOptions)

LoadOption is the type used to configure the load of elements

func DefaultType

func DefaultType(t 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 Names

func Names(names ...string) LoadOption

Names sets the names 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

func WithTypes

func WithTypes(coltypes map[string]Type) LoadOption

WithTypes sets the types option for loadOptions.

type NDArray added in v1.3.2

type NDArray struct {
	// contains filtered or unexported fields
}

NDArray series多属性封装实现

func (*NDArray) Add added in v1.3.2

func (this *NDArray) Add(x any) Series

func (*NDArray) And added in v1.3.2

func (this *NDArray) And(x any) Series

func (*NDArray) Append added in v1.3.2

func (this *NDArray) Append(values ...any) Series

func (*NDArray) Apply added in v1.3.2

func (this *NDArray) Apply(f func(idx int, v any))

func (*NDArray) Apply2 added in v1.3.2

func (this *NDArray) Apply2(f func(idx int, v any) any, args ...bool) Series

func (*NDArray) ArgMax added in v1.3.2

func (this *NDArray) ArgMax() int

func (*NDArray) ArgMin added in v1.3.2

func (this *NDArray) ArgMin() int

func (*NDArray) Bools added in v1.3.2

func (this *NDArray) Bools() []bool

func (*NDArray) Concat added in v1.3.2

func (this *NDArray) Concat(x Series) Series

func (*NDArray) Copy added in v1.3.2

func (this *NDArray) Copy() Series

func (*NDArray) DTypes added in v1.3.2

func (this *NDArray) DTypes() []num.DType

func (*NDArray) Diff added in v1.3.2

func (this *NDArray) Diff(param any) (s Series)

func (*NDArray) Div added in v1.3.2

func (this *NDArray) Div(x any) Series

func (*NDArray) EWM added in v1.3.2

func (this *NDArray) EWM(alpha EW) ExponentialMovingWindow

func (*NDArray) Empty added in v1.3.2

func (this *NDArray) Empty(t ...Type) Series

func (*NDArray) Eq added in v1.3.2

func (this *NDArray) Eq(x any) Series

func (*NDArray) FillNa added in v1.3.2

func (this *NDArray) FillNa(x any, inplace bool) Series

func (*NDArray) Float32s added in v1.3.3

func (this *NDArray) Float32s() []float32

func (*NDArray) Float64s added in v1.3.3

func (this *NDArray) Float64s() []float64

func (*NDArray) Gt added in v1.3.2

func (this *NDArray) Gt(x any) Series

func (*NDArray) Gte added in v1.3.2

func (this *NDArray) Gte(x any) Series

func (*NDArray) IndexOf added in v1.3.2

func (this *NDArray) IndexOf(index int, opt ...any) any

func (*NDArray) Int32s added in v1.3.3

func (this *NDArray) Int32s() []int32

func (*NDArray) Int64s added in v1.3.3

func (this *NDArray) Int64s() []int64

func (*NDArray) Ints added in v1.3.2

func (this *NDArray) Ints() []int

func (*NDArray) Len added in v1.3.2

func (this *NDArray) Len() int

func (*NDArray) Less added in v1.3.2

func (this *NDArray) Less(i, j int) bool

func (*NDArray) Logic added in v1.3.2

func (this *NDArray) Logic(f func(idx int, v any) bool) []bool

func (*NDArray) Lt added in v1.3.2

func (this *NDArray) Lt(x any) Series

func (*NDArray) Lte added in v1.3.2

func (this *NDArray) Lte(x any) Series

func (*NDArray) Max added in v1.3.2

func (this *NDArray) Max() any

func (*NDArray) Mean added in v1.3.2

func (this *NDArray) Mean() num.DType

func (*NDArray) Min added in v1.3.2

func (this *NDArray) Min() any

func (*NDArray) Mul added in v1.3.2

func (this *NDArray) Mul(x any) Series

func (*NDArray) NaN added in v1.3.2

func (this *NDArray) NaN() any

func (*NDArray) Name added in v1.3.2

func (this *NDArray) Name() string

func (*NDArray) Neq added in v1.3.2

func (this *NDArray) Neq(x any) Series

func (*NDArray) Not added in v1.3.2

func (this *NDArray) Not() Series

func (*NDArray) Or added in v1.3.2

func (this *NDArray) Or(x any) Series

func (*NDArray) Records added in v1.3.2

func (this *NDArray) Records(round ...bool) []string

func (*NDArray) Ref added in v1.3.2

func (this *NDArray) Ref(periods any) (s Series)

func (*NDArray) Rename added in v1.3.2

func (this *NDArray) Rename(name string)

func (*NDArray) Repeat added in v1.3.2

func (this *NDArray) Repeat(x any, repeats int) Series

func (*NDArray) Reverse added in v1.3.2

func (this *NDArray) Reverse() Series

func (*NDArray) Rolling added in v1.3.2

func (this *NDArray) Rolling(param any) RollingAndExpandingMixin

func (*NDArray) Select added in v1.3.2

func (this *NDArray) Select(r api.ScopeLimit) Series

func (*NDArray) Shift added in v1.3.2

func (this *NDArray) Shift(periods int) Series

func (*NDArray) Std added in v1.3.2

func (this *NDArray) Std() num.DType

func (*NDArray) StdDev added in v1.3.2

func (this *NDArray) StdDev() num.DType

func (*NDArray) String added in v1.3.3

func (this *NDArray) String() string

func (*NDArray) Strings added in v1.3.2

func (this *NDArray) Strings() []string

func (*NDArray) Sub added in v1.3.2

func (this *NDArray) Sub(x any) Series

func (*NDArray) Subset added in v1.3.2

func (this *NDArray) Subset(start, end int, opt ...any) Series

func (*NDArray) Sum added in v1.3.2

func (this *NDArray) Sum() num.DType

func (*NDArray) Swap added in v1.3.2

func (this *NDArray) Swap(i, j int)

func (*NDArray) Type added in v1.3.2

func (this *NDArray) Type() Type

func (*NDArray) Values added in v1.3.2

func (this *NDArray) Values() any

type RollingAndExpandingMixin added in v0.6.3

type RollingAndExpandingMixin struct {
	//Window []num.DType
	Window num.Window[num.DType]
	Series Series
}

RollingAndExpandingMixin 滚动和扩展静态横切

func (RollingAndExpandingMixin) Aggregation added in v1.3.3

func (r RollingAndExpandingMixin) Aggregation(f func(S Series) any) Series

Aggregation 接受一个聚合回调

func (RollingAndExpandingMixin) Apply added in v0.6.4

func (r RollingAndExpandingMixin) Apply(f func(S Series, N num.DType) num.DType) (s Series)

Apply 接受一个返回DType计算类回调函数

func (RollingAndExpandingMixin) Count added in v0.6.4

func (r RollingAndExpandingMixin) Count() Series

func (RollingAndExpandingMixin) GetBlocks added in v1.3.2

func (r RollingAndExpandingMixin) GetBlocks() (blocks []Series)

GetBlocks series分块

func (RollingAndExpandingMixin) Max added in v0.6.4

Max 最大值

func (RollingAndExpandingMixin) Mean added in v0.6.3

func (r RollingAndExpandingMixin) Mean() (s Series)

Mean returns the rolling mean.

func (RollingAndExpandingMixin) Min added in v0.6.4

Min 最小值

func (RollingAndExpandingMixin) Std added in v0.6.4

func (RollingAndExpandingMixin) Sum added in v0.6.4

type ScalarAggregation added in v1.3.3

type ScalarAggregation interface {
	// Mean calculates the average value of a series
	Mean() num.DType
	// StdDev calculates the standard deviation of a series
	StdDev() num.DType
	// Max 找出最大值
	Max() any
	// ArgMax Returns the indices of the maximum values along an axis
	ArgMax() int
	// Min 找出最小值
	Min() any
	// ArgMin Returns the indices of the minimum values along an axis
	ArgMin() int
	// Diff 元素的第一个离散差
	Diff(param any) (s Series)
	// Std 计算标准差
	Std() num.DType
	// Sum 计算累和
	Sum() num.DType
	// Add 加
	Add(x any) Series
	// Sub 减
	Sub(x any) Series
	// Mul 乘
	Mul(x any) Series
	// Div 除
	Div(x any) Series
	// Eq 等于
	Eq(x any) Series
	// Neq 不等于
	Neq(x any) Series
	// Gt 大于
	Gt(x any) Series
	// Gte 大于等于
	Gte(x any) Series
	// Lt 小于
	Lt(x any) Series
	// Lte 小于等于
	Lte(x any) Series
	// And 与
	And(x any) Series
	// Or 或
	Or(x any) Series
	// Not 非
	Not() Series
}

ScalarAggregation 标量聚合接口

type SelectIndexes added in v0.6.4

type SelectIndexes any

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 Series

type Series interface {
	String() string
	// Name 取得series名称
	Name() string
	// Rename renames the series.
	Rename(name string)
	// Type returns the type of Data the series holds.
	// 返回series的数据类型
	Type() Type
	// Values 获得全部数据集
	Values() any
	// NaN 输出默认的NaN
	NaN() any

	// DTypes 强制转[]num.DType
	DTypes() []num.DType
	// Float32s 强制转成[]float32
	Float32s() []float32
	// Float64s 强制转成[]float64
	Float64s() []float64
	// Ints 强制转换成[]int
	Ints() []int
	// Int32s 强制转换成[]int32
	Int32s() []int32
	// Int64s 强制转换成[]int64
	Int64s() []int64
	// Strings 强制转换string切片
	Strings() []string
	// Bools 强制转换成bool切片
	Bools() []bool

	// Len 获得行数, 实现sort.Interface接口的获取元素数量方法
	Len() int
	// Less 实现sort.Interface接口的比较元素方法
	Less(i, j int) bool
	// Swap 实现sort.Interface接口的交换元素方法
	Swap(i, j int)

	// Empty returns an empty Series of the same type
	Empty(t ...Type) Series
	// Copy 复制
	Copy() Series
	// Reverse 序列反转
	Reverse() Series
	// Select 选取一段记录
	Select(r api.ScopeLimit) Series
	// Append 增加一批记录
	Append(values ...any) Series
	// Concat concatenates two series together. It will return a new Series with the
	// combined elements of both Series.
	Concat(x Series) Series

	// Records returns the elements of a Series as a []string
	Records(round ...bool) []string
	// IndexOf 取一条记录, index<0时, 从后往前取值
	IndexOf(index int, opt ...any) any
	// Subset 获取子集
	Subset(start, end int, opt ...any) Series
	// Repeat elements of an array.
	Repeat(x any, repeats int) Series
	// FillNa Fill NA/NaN values using the specified method.
	FillNa(v any, inplace bool) Series

	// Ref 引用其它周期的数据
	Ref(periods any) (s Series)
	// Shift index by desired number of periods with an optional time freq.
	//	使用可选的时间频率按所需的周期数移动索引.
	Shift(periods int) Series
	// Rolling 序列化版本
	Rolling(param any) RollingAndExpandingMixin
	// Apply 接受一个回调函数
	Apply(f func(idx int, v any))
	// Apply2 增加替换功能, 默认不替换
	Apply2(f func(idx int, v any) any, args ...bool) Series
	// Logic 逻辑处理
	Logic(f func(idx int, v any) bool) []bool
	// EWM Provide exponentially weighted (EW) calculations.
	//
	//	Exactly one of “com“, “span“, “halflife“, or “alpha“ must be
	//	provided if “times“ is not provided. If “times“ is provided,
	//	“halflife“ and one of “com“, “span“ or “alpha“ may be provided.
	EWM(alpha EW) ExponentialMovingWindow

	// Mean calculates the average value of a series
	Mean() num.DType
	// StdDev calculates the standard deviation of a series
	StdDev() num.DType
	// Max 找出最大值
	Max() any
	// ArgMax Returns the indices of the maximum values along an axis
	ArgMax() int
	// Min 找出最小值
	Min() any
	// ArgMin Returns the indices of the minimum values along an axis
	ArgMin() int
	// Diff 元素的第一个离散差
	Diff(param any) (s Series)
	// Std 计算标准差
	Std() num.DType
	// Sum 计算累和
	Sum() num.DType
	// Add 加
	Add(x any) Series
	// Sub 减
	Sub(x any) Series
	// Mul 乘
	Mul(x any) Series
	// Div 除
	Div(x any) Series
	// Eq 等于
	Eq(x any) Series
	// Neq 不等于
	Neq(x any) Series
	// Gt 大于
	Gt(x any) Series
	// Gte 大于等于
	Gte(x any) Series
	// Lt 小于
	Lt(x any) Series
	// Lte 小于等于
	Lte(x any) Series
	// And 与
	And(x any) Series
	// Or 或
	Or(x any) Series
	// Not 非
	Not() Series
}

Series

Data structure for 1-dimensional cross-sectional and time series data
一维横截面和时间序列数据的数据结构

func Align2Series added in v1.3.2

func Align2Series(x any, N int) Series

Align2Series any转换成series

N=-1, 即为全部

func NewSeries

func NewSeries[T num.BaseType](values ...T) Series

NewSeries 模糊匹配泛型切片的匿名series

func NewSeriesWithType added in v0.6.3

func NewSeriesWithType(typ Type, name string, values ...any) Series

NewSeriesWithType 指定series类型, 强制导入values

推导values中最适合的类型

func NewSeriesWithoutType added in v0.6.3

func NewSeriesWithoutType(name string, values ...any) Series

NewSeriesWithoutType 不带类型, 创建一个新series

推导values中最适合的类型

func NewVector added in v1.3.3

func NewVector[T num.BaseType](values ...T) Series

NewVector 创建一个新的向量

func SeriesWithName added in v1.3.3

func SeriesWithName[T num.BaseType](name string, data ...T) Series

SeriesWithName 构建一个新的Series

指定类型T和名称

func ToSeries added in v1.3.2

func ToSeries[T num.BaseType](data ...T) Series

ToSeries 转换切片为Series

type Type

type Type = reflect.Kind

Type is a convenience alias that can be used for a more type safe way of reason and use Series types.

func DetectTypeBySlice added in v1.3.2

func DetectTypeBySlice(arr ...any) (Type, error)

DetectTypeBySlice 检测类型

type Vector added in v1.3.3

type Vector[T num.BaseType] []T

Vector 泛型向量

func (Vector[T]) Add added in v1.3.3

func (this Vector[T]) Add(x any) Series

func (Vector[T]) And added in v1.3.3

func (this Vector[T]) And(x any) Series

func (Vector[T]) Append added in v1.3.3

func (this Vector[T]) Append(values ...any) Series

func (Vector[T]) Apply added in v1.3.3

func (this Vector[T]) Apply(f func(idx int, v any))

func (Vector[T]) Apply2 added in v1.3.3

func (this Vector[T]) Apply2(f func(idx int, v any) any, args ...bool) Series

Apply2 提供可替换功能的apply方法, 默认不替换

func (Vector[T]) ArgMax added in v1.3.3

func (this Vector[T]) ArgMax() int

func (Vector[T]) ArgMin added in v1.3.3

func (this Vector[T]) ArgMin() int

func (Vector[T]) Bools added in v1.3.3

func (this Vector[T]) Bools() []bool

func (Vector[T]) Concat added in v1.3.3

func (this Vector[T]) Concat(x Series) Series

func (Vector[T]) Copy added in v1.3.3

func (this Vector[T]) Copy() Series

func (Vector[T]) DTypes added in v1.3.3

func (this Vector[T]) DTypes() []num.DType

func (Vector[T]) Diff added in v1.3.3

func (this Vector[T]) Diff(n any) Series

func (Vector[T]) Div added in v1.3.3

func (this Vector[T]) Div(x any) Series

func (Vector[T]) EWM added in v1.3.3

func (this Vector[T]) EWM(alpha EW) ExponentialMovingWindow

func (Vector[T]) Empty added in v1.3.3

func (this Vector[T]) Empty(tv ...Type) Series

func (Vector[T]) Eq added in v1.3.3

func (this Vector[T]) Eq(x any) Series

func (Vector[T]) FillNa added in v1.3.3

func (this Vector[T]) FillNa(v any, inplace bool) Series

func (Vector[T]) Float32s added in v1.3.3

func (this Vector[T]) Float32s() []float32

func (Vector[T]) Float64s added in v1.3.3

func (this Vector[T]) Float64s() []float64

func (Vector[T]) Gt added in v1.3.3

func (this Vector[T]) Gt(x any) Series

func (Vector[T]) Gte added in v1.3.3

func (this Vector[T]) Gte(x any) Series

func (Vector[T]) IndexOf added in v1.3.3

func (this Vector[T]) IndexOf(index int, opt ...any) any

func (Vector[T]) Int32s added in v1.3.3

func (this Vector[T]) Int32s() []int32

func (Vector[T]) Int64s added in v1.3.3

func (this Vector[T]) Int64s() []int64

func (Vector[T]) Ints added in v1.3.3

func (this Vector[T]) Ints() []int

func (Vector[T]) Len added in v1.3.3

func (this Vector[T]) Len() int

func (Vector[T]) Less added in v1.3.3

func (this Vector[T]) Less(i, j int) bool

Less 实现sort.Interface接口的比较元素方法

func (Vector[T]) Logic added in v1.3.3

func (this Vector[T]) Logic(f func(idx int, v any) bool) []bool

func (Vector[T]) Lt added in v1.3.3

func (this Vector[T]) Lt(x any) Series

func (Vector[T]) Lte added in v1.3.3

func (this Vector[T]) Lte(x any) Series

func (Vector[T]) Max added in v1.3.3

func (this Vector[T]) Max() any

func (Vector[T]) Mean added in v1.3.3

func (this Vector[T]) Mean() num.DType

func (Vector[T]) Min added in v1.3.3

func (this Vector[T]) Min() any

func (Vector[T]) Mul added in v1.3.3

func (this Vector[T]) Mul(x any) Series

func (Vector[T]) NaN added in v1.3.3

func (this Vector[T]) NaN() any

func (Vector[T]) Name added in v1.3.3

func (this Vector[T]) Name() string

func (Vector[T]) Neq added in v1.3.3

func (this Vector[T]) Neq(x any) Series

func (Vector[T]) Not added in v1.3.3

func (this Vector[T]) Not() Series

func (Vector[T]) Or added in v1.3.3

func (this Vector[T]) Or(x any) Series

func (Vector[T]) Records added in v1.3.3

func (this Vector[T]) Records(round ...bool) []string

func (Vector[T]) Ref added in v1.3.3

func (this Vector[T]) Ref(n any) Series

func (Vector[T]) Rename added in v1.3.3

func (this Vector[T]) Rename(name string)

func (Vector[T]) Repeat added in v1.3.3

func (this Vector[T]) Repeat(x any, repeats int) Series

func (Vector[T]) Reverse added in v1.3.3

func (this Vector[T]) Reverse() Series

func (Vector[T]) Rolling added in v1.3.3

func (this Vector[T]) Rolling(param any) RollingAndExpandingMixin

func (Vector[T]) Select added in v1.3.3

func (this Vector[T]) Select(r api.ScopeLimit) Series

func (Vector[T]) Shift added in v1.3.3

func (this Vector[T]) Shift(periods int) Series

func (Vector[T]) Std added in v1.3.3

func (this Vector[T]) Std() num.DType

func (Vector[T]) StdDev added in v1.3.3

func (this Vector[T]) StdDev() num.DType

func (Vector[T]) String added in v1.3.3

func (this Vector[T]) String() string

func (Vector[T]) Strings added in v1.3.3

func (this Vector[T]) Strings() []string

func (Vector[T]) Sub added in v1.3.3

func (this Vector[T]) Sub(x any) Series

func (Vector[T]) Subset added in v1.3.3

func (this Vector[T]) Subset(start, end int, opt ...any) Series

func (Vector[T]) Sum added in v1.3.3

func (this Vector[T]) Sum() num.DType

func (Vector[T]) Swap added in v1.3.3

func (this Vector[T]) Swap(i, j int)

Swap 实现sort.Interface接口的交换元素方法

func (Vector[T]) Type added in v1.3.3

func (this Vector[T]) Type() Type

func (Vector[T]) Values added in v1.3.3

func (this Vector[T]) 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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