pandas

package module
v1.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 31

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

Examples

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_STRING  = reflect.String      // string
	SERIES_TYPE_DTYPE   = SERIES_TYPE_FLOAT64 // link float64
)

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 (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.

选取一列, Col方法的目的是保持现有的name等字段

func (DataFrame) ColAsNDArray added in v0.6.6

func (this DataFrame) ColAsNDArray(colname string) Series

ColAsNDArray 切换成vector的无名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两种方式写入数据

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 NDFrame

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

NDFrame series多属性封装实现

func (*NDFrame) Add added in v0.6.6

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

func (*NDFrame) And added in v0.6.7

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

func (*NDFrame) Append added in v0.6.3

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

func (*NDFrame) Apply added in v0.6.3

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

func (*NDFrame) Apply2 added in v0.6.16

func (this *NDFrame) Apply2(f func(idx int, v any) any, inplace ...bool) Series

func (*NDFrame) ArgMax added in v0.6.6

func (this *NDFrame) ArgMax() int

func (*NDFrame) ArgMin added in v0.6.6

func (this *NDFrame) ArgMin() int

func (*NDFrame) Bools added in v0.7.9

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

func (*NDFrame) Concat added in v0.6.16

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

func (*NDFrame) Copy

func (this *NDFrame) Copy() Series

func (*NDFrame) DTypes added in v0.6.4

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

func (*NDFrame) Diff added in v0.6.3

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

func (*NDFrame) Div added in v0.6.6

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

func (*NDFrame) EWM added in v0.6.4

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

func (*NDFrame) Empty

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

func (*NDFrame) Eq added in v0.6.7

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

func (*NDFrame) FillNa added in v0.6.2

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

func (*NDFrame) Float32s added in v1.3.4

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

func (*NDFrame) Float64s added in v1.3.4

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

func (*NDFrame) Gt added in v0.6.7

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

func (*NDFrame) Gte added in v0.6.7

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

func (*NDFrame) IndexOf added in v0.6.18

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

func (*NDFrame) Int32s added in v1.3.4

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

func (*NDFrame) Int64s added in v1.3.4

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

func (*NDFrame) Ints added in v0.6.6

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

func (*NDFrame) Len

func (this *NDFrame) Len() int

func (*NDFrame) Less added in v0.6.4

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

func (*NDFrame) Logic added in v0.6.4

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

func (*NDFrame) Lt added in v0.6.7

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

func (*NDFrame) Lte added in v0.6.7

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

func (*NDFrame) Max added in v0.6.2

func (this *NDFrame) Max() any

func (*NDFrame) Mean

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

func (*NDFrame) Min added in v0.6.2

func (this *NDFrame) Min() any

func (*NDFrame) Mul added in v0.6.6

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

func (*NDFrame) NaN added in v0.6.4

func (this *NDFrame) NaN() any

func (*NDFrame) Name

func (this *NDFrame) Name() string

func (*NDFrame) Neq added in v1.2.4

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

func (*NDFrame) Not added in v1.2.4

func (this *NDFrame) Not() Series

func (*NDFrame) Or added in v1.1.0

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

func (*NDFrame) Records

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

func (*NDFrame) Ref added in v0.6.4

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

func (*NDFrame) Rename

func (this *NDFrame) Rename(name string)

func (*NDFrame) Repeat

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

func (*NDFrame) Reverse added in v0.6.6

func (this *NDFrame) Reverse() Series

func (*NDFrame) Rolling

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

func (*NDFrame) Select added in v0.6.3

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

func (*NDFrame) Set added in v1.3.8

func (this *NDFrame) Set(index int, v any)

func (*NDFrame) Shift

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

func (*NDFrame) Std added in v0.6.4

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

func (*NDFrame) StdDev

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

func (*NDFrame) String added in v1.3.4

func (this *NDFrame) String() string

func (*NDFrame) Strings added in v0.6.22

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

func (*NDFrame) Sub added in v0.6.6

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

func (*NDFrame) Subset

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

func (*NDFrame) Sum added in v0.6.4

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

func (*NDFrame) Swap added in v0.6.4

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

func (*NDFrame) Type

func (this *NDFrame) Type() Type

func (*NDFrame) Values

func (this *NDFrame) Values() any

type RollingAndExpandingMixin added in v0.6.3

type RollingAndExpandingMixin struct {
	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)

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)

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
	// Set 赋值
	Set(index int, v 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, inplace ...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
一维横截面和时间序列数据的数据结构
pandas中Series无法确定类型的情况下会使用string保存切片

func Align2Series added in v1.3.2

func Align2Series(x any, N int) Series

Align2Series any转换成series

N=-1, 即为全部

func Convect added in v1.3.5

func Convect[T num.BaseType, F num.BaseType](data []F) Series

Convect 切片转series

存在可能的强制转换类型
Example
v1 := []float64{1.1, 2.2, 3.3}
v2 := Convect[float64](v1)
fmt.Println(v2)
// Output
// dtype[int]: 1,2,3
Output:

func NewSeries

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

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

func NewSeriesWithType added in v0.6.3

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

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

推导values中最适合的类型, DataFrame内部调用

func NewSeriesWithoutType added in v0.6.3

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

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

推导values中最适合的类型, DataFrame内部调用

func SeriesWithName added in v1.3.3

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

SeriesWithName 构建一个新的Series, NDFrame

指定类型T和名称

func SeriesWithoutName added in v1.3.5

func SeriesWithoutName[E num.BaseType](values ...E) Series

SeriesWithoutName 创建一个新的匿名Series

func SliceToSeries added in v1.3.4

func SliceToSeries[E num.BaseType](data []E) Series

SliceToSeries 切片转Series

data大概率是长度大于0的切片, 这样的函数签名是为了泛型函数不写数据类型

func ToSeries added in v1.3.2

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

ToSeries 转换切片为Series

func ToVector added in v1.3.5

func ToVector[E num.BaseType](data ...E) Series

ToVector 转成单一切片

这种用法潜在的意图是类型明确, data可能是长度为0的切片, 但是又不想传入参数, 故而实用了默认参数的用法

func Vector added in v1.3.3

func Vector[E num.BaseType](data []E) Series

Vector 切片转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 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