Documentation
¶
Index ¶
- Variables
- func LogDebug(msg string, args ...interface{})
- func LogFatal(msg string, args ...interface{})
- func LogInfo(msg string, args ...interface{})
- func LogWarning(msg string, args ...interface{})
- func ProcessData(input interface{}) ([]interface{}, int)
- func SetDefaultConfig()
- func SliceToF64(data []interface{}) []float64
- func SqrtRat(x *big.Rat) *big.Rat
- func ToFloat64(v interface{}) float64
- func ToFloat64Safe(v interface{}) (float64, bool)
- type DataList
- func (dl *DataList) Append(values ...interface{})
- func (dl *DataList) Capitalize()
- func (dl *DataList) Clear()
- func (dl *DataList) ClearNumbers()
- func (dl *DataList) ClearStrings()
- func (dl *DataList) Count(value interface{}) int
- func (dl *DataList) Data() []interface{}
- func (dl *DataList) Drop(index int)
- func (dl *DataList) DropAll(toDrop ...interface{})
- func (dl *DataList) Filter(filterFunc func(interface{}) bool) *DataList
- func (dl *DataList) FindAll(value interface{}) []int
- func (dl *DataList) FindFirst(value interface{}) interface{}
- func (dl *DataList) FindLast(value interface{}) interface{}
- func (dl *DataList) GMean() interface{}
- func (dl *DataList) Get(index int) interface{}
- func (dl *DataList) GetCreationTimestamp() int64
- func (dl *DataList) GetLastModifiedTimestamp() int64
- func (dl *DataList) GetName() string
- func (dl *DataList) IQR() interface{}
- func (dl *DataList) InsertAt(index int, value interface{})
- func (dl *DataList) Len() int
- func (dl *DataList) Lower()
- func (dl *DataList) Mad() interface{}
- func (dl *DataList) Max() interface{}
- func (dl *DataList) Mean(highPrecision ...bool) interface{}
- func (dl *DataList) Median(highPrecision ...bool) interface{}
- func (dl *DataList) Min() interface{}
- func (dl *DataList) Mode() interface{}
- func (dl *DataList) ParseNumbers()
- func (dl *DataList) ParseStrings()
- func (dl *DataList) Percentile(p float64) interface{}
- func (dl *DataList) Pop() interface{}
- func (dl *DataList) Quartile(q int) interface{}
- func (dl *DataList) Range() interface{}
- func (dl *DataList) ReplaceAll(oldValue, newValue interface{})
- func (dl *DataList) ReplaceFirst(oldValue, newValue interface{})
- func (dl *DataList) ReplaceLast(oldValue, newValue interface{})
- func (dl *DataList) Reverse()
- func (dl *DataList) SetName(newName string)
- func (dl *DataList) Sort(ascending ...bool)
- func (dl *DataList) Stdev(highPrecision ...bool) interface{}
- func (dl *DataList) StdevP(highPrecision ...bool) interface{}
- func (dl *DataList) Sum() interface{}
- func (dl *DataList) ToF64Slice() []float64
- func (dl *DataList) ToStringSlice() []string
- func (dl *DataList) Update(index int, newValue interface{})
- func (dl *DataList) Upper()
- func (dl *DataList) Var(highPrecision ...bool) interface{}
- func (dl *DataList) VarP(highPrecision ...bool) interface{}
- type DataTable
- func (dt *DataTable) AppendColumns(columns ...*DataList)
- func (dt *DataTable) AppendRowsByIndex(rowsData ...map[string]interface{})
- func (dt *DataTable) AppendRowsByName(rowsData ...map[string]interface{})
- func (dt *DataTable) AppendRowsFromDataList(rowsData ...*DataList)
- func (dt *DataTable) Data(useNamesAsKeys ...bool) map[string][]interface{}
- func (dt *DataTable) DropColumnsByIndex(columnIndices ...string)
- func (dt *DataTable) DropColumnsByName(columnNames ...string)
- func (dt *DataTable) DropRowsByIndex(rowIndices ...int)
- func (dt *DataTable) DropRowsByName(rowNames ...string)
- func (dt *DataTable) GetCreationTimestamp() int64
- func (dt *DataTable) GetLastModifiedTimestamp() int64
- func (dt *DataTable) Show()
- type IDataList
- type IDataTable
- type LogLevel
- type NameManager
Constants ¶
This section is empty.
Variables ¶
var Config *configStruct
Functions ¶
func LogWarning ¶
func LogWarning(msg string, args ...interface{})
func ProcessData ¶
func ProcessData(input interface{}) ([]interface{}, int)
ProcessData processes the input data and returns the data and the length of the data. Returns nil and 0 if the data type is unsupported. Supported data types are []interface{} and IDataList.
func SetDefaultConfig ¶
func SetDefaultConfig()
======================== Configs ======================== DefaultConfig returns a Config with default values.
func SliceToF64 ¶
func SliceToF64(data []interface{}) []float64
func ToFloat64 ¶
func ToFloat64(v interface{}) float64
ToFloat64 converts any numeric value to float64.
func ToFloat64Safe ¶
ToFloat64Safe tries to convert any numeric value to float64 and returns a boolean indicating success.
Types ¶
type DataList ¶
type DataList struct {
// contains filtered or unexported fields
}
DataList is a generic dynamic data list.
func NewDataList ¶
func NewDataList(values ...interface{}) *DataList
NewDataList creates a new DataList, supporting both slice and variadic inputs, and flattens the input before storing it.
func (*DataList) Append ¶
func (dl *DataList) Append(values ...interface{})
Append adds a new values to the DataList. The value can be of any type. The value is appended to the end of the DataList.
func (*DataList) Capitalize ¶
func (dl *DataList) Capitalize()
Capitalize capitalizes the first letter of each string element in the DataList.
func (*DataList) Clear ¶
func (dl *DataList) Clear()
Clear removes all elements from the DataList and updates the timestamp.
func (*DataList) ClearNumbers ¶
func (dl *DataList) ClearNumbers()
ClearNumbers removes all numeric elements (int, float, etc.) from the DataList and updates the timestamp.
func (*DataList) ClearStrings ¶
func (dl *DataList) ClearStrings()
ClearStrings removes all string elements from the DataList and updates the timestamp.
func (*DataList) Count ¶ added in v0.0.1
Count returns the number of occurrences of the specified value in the DataList.
func (*DataList) Data ¶
func (dl *DataList) Data() []interface{}
Data returns the data stored in the DataList.
func (*DataList) Drop ¶
Drop removes the element at the specified index from the DataList and updates the timestamp. Returns an error if the index is out of bounds.
func (*DataList) DropAll ¶
func (dl *DataList) DropAll(toDrop ...interface{})
DropAll removes all occurrences of the specified values from the DataList. Supports multiple values to drop.
func (*DataList) Filter ¶
Filter filters the DataList based on a custom filter function provided by the user. The filter function should return true for elements that should be included in the result.
func (*DataList) FindAll ¶
FindAll returns a slice of all the indices where the specified value is found in the DataList using parallel processing. If the value is not found, it returns an empty slice.
func (*DataList) FindFirst ¶
func (dl *DataList) FindFirst(value interface{}) interface{}
FindFirst returns the index of the first occurrence of the specified value in the DataList. If the value is not found, it returns nil.
func (*DataList) FindLast ¶
func (dl *DataList) FindLast(value interface{}) interface{}
FindLast returns the index of the last occurrence of the specified value in the DataList. If the value is not found, it returns nil.
func (*DataList) GMean ¶
func (dl *DataList) GMean() interface{}
GMean calculates the geometric mean of the DataList. Returns the geometric mean. Returns nil if the DataList is empty. GMean returns the geometric mean of the DataList.
func (*DataList) Get ¶
Get retrieves the value at the specified index in the DataList. Supports negative indexing. Returns nil if the index is out of bounds. Returns the value at the specified index.
func (*DataList) GetCreationTimestamp ¶
GetCreationTimestamp returns the creation time of the DataList in Unix timestamp.
func (*DataList) GetLastModifiedTimestamp ¶
GetLastModifiedTimestamp returns the last updated time of the DataList in Unix timestamp.
func (*DataList) IQR ¶
func (dl *DataList) IQR() interface{}
IQR calculates the interquartile range of the DataList. Returns the interquartile range. Returns nil if the DataList is empty.
func (*DataList) InsertAt ¶
InsertAt inserts a value at the specified index in the DataList. If the index is out of bounds, the value is appended to the end of the list.
func (*DataList) Lower ¶
func (dl *DataList) Lower()
Lower converts all string elements in the DataList to lowercase.
func (*DataList) Mad ¶ added in v0.0.1
func (dl *DataList) Mad() interface{}
Mad calculates the mean absolute deviation of the DataList. Returns the mean absolute deviation. Returns nil if the DataList is empty.
func (*DataList) Max ¶
func (dl *DataList) Max() interface{}
Max returns the maximum value in the DataList. Returns the maximum value. Returns nil if the DataList is empty. Max returns the maximum value in the DataList, or nil if the data types cannot be compared.
func (*DataList) Mean ¶
Mean calculates the arithmetic mean of the DataList. If highPrecision is true, it will calculate using big.Rat for high precision. Otherwise, it calculates using float64. Returns nil if the DataList is empty or if an invalid number of parameters is provided.
func (*DataList) Median ¶
Median calculates the median of the DataList. Returns the median. Returns nil if the DataList is empty. Turn on highPrecision to return a big.Rat instead of a float64.
func (*DataList) Min ¶
func (dl *DataList) Min() interface{}
Min returns the minimum value in the DataList. Returns the minimum value. Returns nil if the DataList is empty. Min returns the minimum value in the DataList, or nil if the data types cannot be compared.
func (*DataList) Mode ¶
func (dl *DataList) Mode() interface{}
Mode calculates the mode of the DataList. Returns the mode. Returns nil if the DataList is empty. Mode returns the mode of the DataList.
func (*DataList) ParseNumbers ¶
func (dl *DataList) ParseNumbers()
ParseNumbers attempts to parse all string elements in the DataList to numeric types. If parsing fails, the element is left unchanged.
func (*DataList) ParseStrings ¶
func (dl *DataList) ParseStrings()
ParseStrings converts all elements in the DataList to strings.
func (*DataList) Percentile ¶
Percentile calculates the percentile based on the input value (0 to 100). Returns the percentile value, or nil if the DataList is empty.
func (*DataList) Pop ¶
func (dl *DataList) Pop() interface{}
Pop removes and returns the last element from the DataList. Returns the last element. Returns nil if the DataList is empty.
func (*DataList) Quartile ¶
Quartile calculates the quartile based on the input value (1 to 3). 1 corresponds to the first quartile (Q1), 2 to the median (Q2), and 3 to the third quartile (Q3).
func (*DataList) Range ¶
func (dl *DataList) Range() interface{}
Range calculates the range of the DataList. Returns the range. Returns nil if the DataList is empty. Range returns the range of the DataList.
func (*DataList) ReplaceAll ¶
func (dl *DataList) ReplaceAll(oldValue, newValue interface{})
ReplaceAll replaces all occurrences of oldValue with newValue in the DataList. If oldValue is not found, no changes are made.
func (*DataList) ReplaceFirst ¶
func (dl *DataList) ReplaceFirst(oldValue, newValue interface{})
ReplaceFirst replaces the first occurrence of oldValue with newValue.
func (*DataList) ReplaceLast ¶
func (dl *DataList) ReplaceLast(oldValue, newValue interface{})
ReplaceLast replaces the last occurrence of oldValue with newValue.
func (*DataList) Reverse ¶
func (dl *DataList) Reverse()
Reverse reverses the order of the elements in the DataList.
func (*DataList) Sort ¶
Sort sorts the DataList using a mixed sorting logic. It handles string, numeric (including all integer and float types), and time data types. If sorting fails, it restores the original order.
func (*DataList) Stdev ¶
Stdev calculates the standard deviation(sample) of the DataList. Returns the standard deviation. Returns nil if the DataList is empty. Stdev returns the standard deviation of the DataList.
func (*DataList) StdevP ¶
StdevP calculates the standard deviation(population) of the DataList. Returns the standard deviation. Returns nil if the DataList is empty or the standard deviation cannot be calculated.
func (*DataList) ToF64Slice ¶
ToF64Slice converts the DataList to a float64 slice. Returns the float64 slice. Returns nil if the DataList is empty. ToF64Slice converts the DataList to a float64 slice.
func (*DataList) ToStringSlice ¶
ToStringSlice converts the DataList to a string slice. Returns the string slice. Returns nil if the DataList is empty.
func (*DataList) Upper ¶
func (dl *DataList) Upper()
Upper converts all string elements in the DataList to uppercase.
type DataTable ¶ added in v0.0.1
type DataTable struct {
// contains filtered or unexported fields
}
func NewDataTable ¶ added in v0.0.1
func (*DataTable) AppendColumns ¶ added in v0.0.1
func (*DataTable) AppendRowsByIndex ¶ added in v0.0.1
func (*DataTable) AppendRowsByName ¶ added in v0.0.1
func (*DataTable) AppendRowsFromDataList ¶ added in v0.0.1
func (*DataTable) DropColumnsByIndex ¶ added in v0.0.1
DropColumnsByIndex drops columns by their index names.
func (*DataTable) DropColumnsByName ¶ added in v0.0.1
DropColumnsByName drops columns by their names.
func (*DataTable) DropRowsByIndex ¶ added in v0.0.1
DropRowsByIndex drops rows by their indices.
func (*DataTable) DropRowsByName ¶ added in v0.0.1
DropRowsByName drops rows by their names.
func (*DataTable) GetCreationTimestamp ¶ added in v0.0.1
func (*DataTable) GetLastModifiedTimestamp ¶ added in v0.0.1
type IDataList ¶
type IDataList interface {
GetCreationTimestamp() int64
GetLastModifiedTimestamp() int64
GetName() string
SetName(string)
Data() []interface{}
Append(values ...interface{})
Get(index int) interface{}
Count(interface{}) int
Update(index int, value interface{})
InsertAt(index int, value interface{})
FindFirst(interface{}) interface{}
FindLast(interface{}) interface{}
FindAll(interface{}) []int
Filter(func(interface{}) bool) *DataList
ReplaceFirst(interface{}, interface{})
ReplaceLast(interface{}, interface{})
ReplaceAll(interface{}, interface{})
Pop() interface{}
Drop(index int)
DropAll(...interface{})
Clear()
ClearStrings()
ClearNumbers()
Len() int
Sort(acending ...bool)
Reverse()
Upper()
Lower()
Capitalize()
Sum() interface{}
Max() interface{}
Min() interface{}
Mean(highPrecision ...bool) interface{}
GMean() interface{}
Median(highPrecision ...bool) interface{}
Mode() interface{}
Mad() interface{}
Stdev(highPrecision ...bool) interface{}
StdevP(highPrecision ...bool) interface{}
Var(highPrecision ...bool) interface{}
VarP(highPrecision ...bool) interface{}
Range() interface{}
Quartile(int) interface{}
IQR() interface{}
Percentile(float64) interface{}
ParseNumbers()
ParseStrings()
ToF64Slice() []float64
ToStringSlice() []string
// contains filtered or unexported methods
}
IDataList defines the behavior expected from a DataList.
type IDataTable ¶ added in v0.0.1
type IDataTable interface {
AppendColumns(columns ...*DataList)
AppendRowsFromDataList(rowsData ...*DataList)
AppendRowsByIndex(rowsData ...map[string]interface{})
AppendRowsByName(rowsData ...map[string]interface{})
DropColumnsByName(columnNames ...string)
DropColumnsByIndex(columnIndices ...string)
DropRowsByIndex(rowIndices ...int)
DropRowsByName(rowNames ...string)
Data(useNamesAsKeys ...bool) map[string][]interface{}
Show()
GetCreationTimestamp() int64
GetLastModifiedTimestamp() int64
// contains filtered or unexported methods
}
type LogLevel ¶
type LogLevel int
const ( // LogLevelDebug is the log level for debug messages. LogLevelDebug LogLevel = iota // LogLevelInfo is the log level for info messages. LogLevelInfo // LogLevelWarning is the log level for warning messages. LogLevelWarning // LogLevelFatal is the log level for fatal messages. LogLevelFatal )
type NameManager ¶
type NameManager struct {
// contains filtered or unexported fields
}