1 Star 4 Fork 11

王布衣 / pandas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dataframe_options.go 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-02-16 16:51 . 调整函数的文件路径
package pandas
import "gitee.com/quant1x/pandas/stat"
// Read/Write Methods
// =================
// LoadOption is the type used to configure the load of elements
type LoadOption func(*loadOptions)
type loadOptions struct {
// Specifies which is the default type in case detectTypes is disabled.
defaultType stat.Type
// If set, the type of each column will be automatically detected unless
// otherwise specified.
detectTypes bool
// If set, the first row of the tabular structure will be used as column
// names.
hasHeader bool
// The names to set as columns names.
names []string
// Defines which values are going to be considered as NaN when parsing from string.
nanValues []string
// Defines the csv delimiter
delimiter rune
// EnablesLazyQuotes
lazyQuotes bool
// Defines the comment delimiter
comment rune
// The types of specific columns can be specified via column name.
types map[string]stat.Type
}
// DefaultType sets the defaultType option for loadOptions.
func DefaultType(t stat.Type) LoadOption {
return func(c *loadOptions) {
c.defaultType = t
}
}
// DetectTypes sets the detectTypes option for loadOptions.
func DetectTypes(b bool) LoadOption {
return func(c *loadOptions) {
c.detectTypes = b
}
}
// HasHeader sets the hasHeader option for loadOptions.
func HasHeader(b bool) LoadOption {
return func(c *loadOptions) {
c.hasHeader = b
}
}
// Names sets the names option for loadOptions.
func Names(names ...string) LoadOption {
return func(c *loadOptions) {
c.names = names
}
}
// NaNValues sets the nanValues option for loadOptions.
func NaNValues(nanValues []string) LoadOption {
return func(c *loadOptions) {
c.nanValues = nanValues
}
}
// WithTypes sets the types option for loadOptions.
func WithTypes(coltypes map[string]stat.Type) LoadOption {
return func(c *loadOptions) {
c.types = coltypes
}
}
// WithDelimiter sets the csv delimiter other than ',', for example '\t'
func WithDelimiter(b rune) LoadOption {
return func(c *loadOptions) {
c.delimiter = b
}
}
// WithLazyQuotes sets csv parsing option to LazyQuotes
func WithLazyQuotes(b bool) LoadOption {
return func(c *loadOptions) {
c.lazyQuotes = b
}
}
// WithComments sets the csv comment line detect to remove lines
func WithComments(b rune) LoadOption {
return func(c *loadOptions) {
c.comment = b
}
}
// WriteOption is the type used to configure the writing of elements
type WriteOption func(*writeOptions)
type writeOptions struct {
// Specifies whether the header is also written
writeHeader bool
}
// WriteHeader sets the writeHeader option for writeOptions.
func WriteHeader(b bool) WriteOption {
return func(c *writeOptions) {
c.writeHeader = b
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/quant1x/pandas.git
git@gitee.com:quant1x/pandas.git
quant1x
pandas
pandas
v0.9.37

搜索帮助

344bd9b3 5694891 D2dac590 5694891