Documentation
¶
Overview ¶
`insyra` main package provides unified interfaces and structures for data manipulation and analysis.
Index ¶
- Constants
- Variables
- func ClearErrors()
- func GetErrorCount() int
- func IsNumeric(v any) bool
- func LogDebug(packageName, funcName, msg string, args ...any)
- func LogFatal(packageName, funcName, msg string, args ...any)
- func LogInfo(packageName, funcName, msg string, args ...any)
- func LogWarning(packageName, funcName, msg string, args ...any)
- func ParseColIndex(colName string) int
- func PopErrorAndCallback(mode ErrPoppingMode, ...)
- func PowRat(base *big.Rat, exponent int) *big.Rat
- func ProcessData(input any) ([]any, int)
- func SetDefaultConfig()
- func Show(label string, object showable, startEnd ...any)
- func SliceToF64(input []any) []float64
- func SortTimes(times []time.Time)
- func SqrtRat(x *big.Rat) *big.Rat
- type DataList
- func (dl *DataList) Append(values ...any)
- func (s *DataList) AtomicDo(f func(*DataList))
- func (dl *DataList) Capitalize() *DataList
- func (dl *DataList) Clear() *DataList
- func (dl *DataList) ClearNaNs() *DataList
- func (dl *DataList) ClearNumbers() *DataList
- func (dl *DataList) ClearOutliers(stdDevs float64) *DataList
- func (dl *DataList) ClearStrings() *DataList
- func (dl *DataList) Clone() *DataList
- func (s *DataList) Close()
- func (dl *DataList) Count(value any) int
- func (dl *DataList) Counter() map[any]int
- func (dl *DataList) Data() []any
- func (dl *DataList) Difference() *DataList
- func (dl *DataList) DoubleExponentialSmoothing(alpha, beta float64) *DataList
- func (dl *DataList) Drop(index int) *DataList
- func (dl *DataList) DropAll(toDrop ...any) *DataList
- func (dl *DataList) DropIfContains(value any) *DataList
- func (dl *DataList) ExponentialSmoothing(alpha float64) *DataList
- func (dl *DataList) FillNaNWithMean() *DataList
- func (dl *DataList) Filter(filterFunc func(any) bool) *DataList
- func (dl *DataList) FindAll(value any) []int
- func (dl *DataList) FindFirst(value any) any
- func (dl *DataList) FindLast(value any) any
- func (dl *DataList) GMean() float64
- func (dl *DataList) Get(index int) any
- func (dl *DataList) GetCreationTimestamp() int64
- func (dl *DataList) GetLastModifiedTimestamp() int64
- func (dl *DataList) GetName() string
- func (dl *DataList) HermiteInterpolation(x float64, derivatives []float64) float64
- func (dl *DataList) IQR() float64
- func (dl *DataList) InsertAt(index int, value any)
- func (dl *DataList) IsEqualTo(anotherDl *DataList) bool
- func (dl *DataList) IsTheSameAs(anotherDl *DataList) bool
- func (dl *DataList) LagrangeInterpolation(x float64) float64
- func (dl *DataList) Len() int
- func (dl *DataList) LinearInterpolation(x float64) float64
- func (dl *DataList) Lower() *DataList
- func (dl *DataList) MAD() float64
- func (dl *DataList) Map(mapFunc func(int, any) any) *DataList
- func (dl *DataList) Max() float64
- func (dl *DataList) Mean() float64
- func (dl *DataList) Median() float64
- func (dl *DataList) Min() float64
- func (dl *DataList) Mode() []float64
- func (dl *DataList) MovingAverage(windowSize int) *DataList
- func (dl *DataList) MovingStdev(windowSize int) *DataList
- func (dl *DataList) NearestNeighborInterpolation(x float64) float64
- func (dl *DataList) NewtonInterpolation(x float64) float64
- func (dl *DataList) Normalize() *DataList
- func (dl *DataList) ParseNumbers() *DataList
- func (dl *DataList) ParseStrings() *DataList
- func (dl *DataList) Percentile(p float64) float64
- func (dl *DataList) Pop() any
- func (dl *DataList) QuadraticInterpolation(x float64) float64
- func (dl *DataList) Quartile(q int) float64
- func (dl *DataList) Range() float64
- func (dl *DataList) Rank() *DataList
- func (dl *DataList) ReplaceAll(oldValue, newValue any)
- func (dl *DataList) ReplaceFirst(oldValue, newValue any)
- func (dl *DataList) ReplaceLast(oldValue, newValue any)
- func (dl *DataList) ReplaceOutliers(stdDevs float64, replacement float64) *DataList
- func (dl *DataList) Reverse() *DataList
- func (dl *DataList) SetName(newName string) *DataList
- func (dl *DataList) Show()
- func (dl *DataList) ShowRange(startEnd ...any)
- func (dl *DataList) ShowTypes()
- func (dl *DataList) ShowTypesRange(startEnd ...any)
- func (dl *DataList) Sort(ascending ...bool) *DataList
- func (dl *DataList) Standardize() *DataList
- func (dl *DataList) Stdev() float64
- func (dl *DataList) StdevP() float64
- func (dl *DataList) Sum() float64
- func (dl *DataList) Summary()
- func (dl *DataList) ToF64Slice() []float64
- func (dl *DataList) ToStringSlice() []string
- func (dl *DataList) Update(index int, newValue any)
- func (dl *DataList) Upper() *DataList
- func (dl *DataList) Var() float64
- func (dl *DataList) VarP() float64
- func (dl *DataList) WeightedMean(weights any) float64
- func (dl *DataList) WeightedMovingAverage(windowSize int, weights any) *DataList
- type DataTable
- func NewDataTable(columns ...*DataList) *DataTable
- func ReadCSV(filePath string, setFirstColToRowNames bool, setFirstRowToColNames bool) (*DataTable, error)
- func ReadCSV_String(csvString string, setFirstColToRowNames bool, setFirstRowToColNames bool) (*DataTable, error)
- func ReadJSON(filePath string) (*DataTable, error)
- func ReadJSON_Bytes(data []byte) (*DataTable, error)
- func ReadSQL(db *gorm.DB, tableName string, options ...ReadSQLOptions) (*DataTable, error)
- func Slice2DToDataTable(data any) (*DataTable, error)
- func (dt *DataTable) AddColUsingCCL(newColName, ccl string) *DataTable
- func (dt *DataTable) AppendCols(columns ...*DataList) *DataTable
- func (dt *DataTable) AppendRowsByColIndex(rowsData ...map[string]any) *DataTable
- func (dt *DataTable) AppendRowsByColName(rowsData ...map[string]any) *DataTable
- func (dt *DataTable) AppendRowsFromDataList(rowsData ...*DataList) *DataTable
- func (dt *DataTable) AtomicDo(f func(*DataTable))
- func (dt *DataTable) ChangeColName(oldName, newName string) *DataTable
- func (dt *DataTable) ChangeRowName(oldName, newName string) *DataTable
- func (dt *DataTable) Clone() *DataTable
- func (dt *DataTable) Close()
- func (dt *DataTable) ColNames() []string
- func (dt *DataTable) ColNamesToFirstRow() *DataTable
- func (dt *DataTable) Count(value any) int
- func (dt *DataTable) Counter() map[any]int
- func (dt *DataTable) Data(useNamesAsKeys ...bool) map[string][]any
- func (dt *DataTable) DropColNames() *DataTable
- func (dt *DataTable) DropColsByIndex(columnIndices ...string)
- func (dt *DataTable) DropColsByName(columnNames ...string)
- func (dt *DataTable) DropColsByNumber(columnIndices ...int)
- func (dt *DataTable) DropColsContain(value ...any)
- func (dt *DataTable) DropColsContainExcelNA()
- func (dt *DataTable) DropColsContainNil()
- func (dt *DataTable) DropColsContainNumbers()
- func (dt *DataTable) DropColsContainStringElements()
- func (dt *DataTable) DropRowNames() *DataTable
- func (dt *DataTable) DropRowsByIndex(rowIndices ...int)
- func (dt *DataTable) DropRowsByName(rowNames ...string)
- func (dt *DataTable) DropRowsContain(value ...any)
- func (dt *DataTable) DropRowsContainExcelNA()
- func (dt *DataTable) DropRowsContainNil()
- func (dt *DataTable) DropRowsContainNumbers()
- func (dt *DataTable) DropRowsContainStringElements()
- func (dt *DataTable) Filter(filterFunc FilterFunc) *DataTable
- func (dt *DataTable) FilterByColIndexEqualTo(columnIndexLetter string) *DataTable
- func (dt *DataTable) FilterByColIndexGreaterThan(columnIndexLetter string) *DataTable
- func (dt *DataTable) FilterByColIndexGreaterThanOrEqualTo(columnIndexLetter string) *DataTable
- func (dt *DataTable) FilterByColIndexLessThan(columnIndexLetter string) *DataTable
- func (dt *DataTable) FilterByColIndexLessThanOrEqualTo(columnIndexLetter string) *DataTable
- func (dt *DataTable) FilterByColNameContains(substring string) *DataTable
- func (dt *DataTable) FilterByColNameEqualTo(columnName string) *DataTable
- func (dt *DataTable) FilterByCustomElement(filterFunc func(value any) bool) *DataTable
- func (dt *DataTable) FilterByRowIndexEqualTo(index int) *DataTable
- func (dt *DataTable) FilterByRowIndexGreaterThan(threshold int) *DataTable
- func (dt *DataTable) FilterByRowIndexGreaterThanOrEqualTo(threshold int) *DataTable
- func (dt *DataTable) FilterByRowIndexLessThan(threshold int) *DataTable
- func (dt *DataTable) FilterByRowIndexLessThanOrEqualTo(threshold int) *DataTable
- func (dt *DataTable) FilterByRowNameContains(substring string) *DataTable
- func (dt *DataTable) FilterByRowNameEqualTo(rowName string) *DataTable
- func (dt *DataTable) FindColsIfAllElementsContainSubstring(substring string) []string
- func (dt *DataTable) FindColsIfAnyElementContainsSubstring(substring string) []string
- func (dt *DataTable) FindColsIfContains(value any) []string
- func (dt *DataTable) FindColsIfContainsAll(values ...any) []string
- func (dt *DataTable) FindRowsIfAllElementsContainSubstring(substring string) []int
- func (dt *DataTable) FindRowsIfAnyElementContainsSubstring(substring string) []int
- func (dt *DataTable) FindRowsIfContains(value any) []int
- func (dt *DataTable) FindRowsIfContainsAll(values ...any) []int
- func (dt *DataTable) GetCol(index string) *DataList
- func (dt *DataTable) GetColByName(name string) *DataList
- func (dt *DataTable) GetColByNumber(index int) *DataList
- func (dt *DataTable) GetColIndexByName(name string) string
- func (dt *DataTable) GetColIndexByNumber(number int) string
- func (dt *DataTable) GetColNameByIndex(index string) string
- func (dt *DataTable) GetColNameByNumber(index int) string
- func (dt *DataTable) GetColNumberByName(name string) int
- func (dt *DataTable) GetCreationTimestamp() int64
- func (dt *DataTable) GetElement(rowIndex int, columnIndex string) any
- func (dt *DataTable) GetElementByNumberIndex(rowIndex int, columnIndex int) any
- func (dt *DataTable) GetLastModifiedTimestamp() int64
- func (dt *DataTable) GetName() string
- func (dt *DataTable) GetRow(index int) *DataList
- func (dt *DataTable) GetRowByName(name string) *DataList
- func (dt *DataTable) GetRowNameByIndex(index int) string
- func (dt *DataTable) Headers() []string
- func (dt *DataTable) Map(mapFunc func(rowIndex int, colIndex string, element any) any) *DataTable
- func (dt *DataTable) Mean() any
- func (dt *DataTable) RowNames() []string
- func (dt *DataTable) RowNamesToFirstCol() *DataTable
- func (dt *DataTable) SetColNameByIndex(index string, name string) *DataTable
- func (dt *DataTable) SetColNameByNumber(numberIndex int, name string) *DataTable
- func (dt *DataTable) SetColNames(colNames []string) *DataTable
- func (dt *DataTable) SetColToRowNames(columnIndex string) *DataTable
- func (dt *DataTable) SetHeaders(headers []string) *DataTable
- func (dt *DataTable) SetName(name string) *DataTable
- func (dt *DataTable) SetRowNameByIndex(index int, name string)
- func (dt *DataTable) SetRowNames(rowNames []string) *DataTable
- func (dt *DataTable) SetRowToColNames(rowIndex int) *DataTable
- func (dt *DataTable) Show()
- func (dt *DataTable) ShowRange(startEnd ...any)
- func (dt *DataTable) ShowTypes()
- func (dt *DataTable) ShowTypesRange(startEnd ...any)
- func (dt *DataTable) SimpleRandomSample(sampleSize int) *DataTable
- func (dt *DataTable) Size() (numRows int, numCols int)
- func (dt *DataTable) SortBy(configs ...DataTableSortConfig) *DataTable
- func (dt *DataTable) Summary()
- func (dt *DataTable) SwapColsByIndex(columnIndex1 string, columnIndex2 string) *DataTable
- func (dt *DataTable) SwapColsByName(columnName1 string, columnName2 string) *DataTable
- func (dt *DataTable) SwapColsByNumber(columnNumber1 int, columnNumber2 int) *DataTable
- func (dt *DataTable) SwapRowsByIndex(rowIndex1 int, rowIndex2 int) *DataTable
- func (dt *DataTable) SwapRowsByName(rowName1 string, rowName2 string) *DataTable
- func (dt *DataTable) To2DSlice() [][]any
- func (dt *DataTable) ToCSV(filePath string, setRowNamesToFirstCol bool, setColNamesToFirstRow bool, ...) error
- func (dt *DataTable) ToJSON(filePath string, useColNames bool) error
- func (dt *DataTable) ToJSON_Bytes(useColNames bool) []byte
- func (dt *DataTable) ToSQL(db *gorm.DB, tableName string, options ...ToSQLOptions) error
- func (dt *DataTable) Transpose() *DataTable
- func (dt *DataTable) UpdateCol(index string, dl *DataList)
- func (dt *DataTable) UpdateColByNumber(index int, dl *DataList)
- func (dt *DataTable) UpdateElement(rowIndex int, columnIndex string, value any)
- func (dt *DataTable) UpdateRow(index int, dl *DataList)
- type DataTableSortConfig
- type ErrPoppingMode
- type F64orRat
- type FilterFunc
- type IDataList
- type IDataTable
- type LogLevel
- type ReadSQLOptions
- type SQLActionIfTableExists
- type ToSQLOptions
Constants ¶
const Version = "0.2.7"
const VersionName = "Pier-2"
Variables ¶
var Config *configStruct = &configStruct{}
var ToFloat64 = utils.ToFloat64
var ToFloat64Safe = utils.ToFloat64Safe
Functions ¶
func ClearErrors ¶ added in v0.2.2
func ClearErrors()
func GetErrorCount ¶ added in v0.2.2
func GetErrorCount() int
func LogWarning ¶
func ParseColIndex ¶ added in v0.2.2
ParseColIndex converts an Excel-like column name (e.g., "A", "Z", "AA") to its 0-based integer index.
func PopErrorAndCallback ¶ added in v0.2.2
func PopErrorAndCallback(mode ErrPoppingMode, callback func(errType LogLevel, packageName string, funcName string, errMsg string))
func ProcessData ¶
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 slices, IDataList, and pointers to these types.
func Show ¶ added in v0.2.6
Show displays the content of any showable object with a label. Automatically deals with nil objects.
func SliceToF64 ¶
SliceToF64 converts a []any to a []float64.
Types ¶
type DataList ¶
type DataList struct {
// contains filtered or unexported fields
}
DataList is a generic dynamic data list.
func NewDataList ¶
NewDataList creates a new DataList, supporting both slice and variadic inputs, and flattens the input before storing it.
func (*DataList) Append ¶
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 ¶
Capitalize capitalizes the first letter of each string element in the DataList.
func (*DataList) ClearNaNs ¶ added in v0.0.5
ClearNaNs removes all NaN values from the DataList and updates the timestamp.
func (*DataList) ClearNumbers ¶
ClearNumbers removes all numeric elements (int, float, etc.) from the DataList and updates the timestamp.
func (*DataList) ClearOutliers ¶ added in v0.0.5
ClearOutliers removes values from the DataList that are outside the specified number of standard deviations. This method modifies the original DataList and returns it.
func (*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) Counter ¶ added in v0.0.12
Counter returns a map of the number of occurrences of each value in the DataList.
func (*DataList) Difference ¶ added in v0.0.5
Difference calculates the differences between adjacent elements in the DataList.
func (*DataList) DoubleExponentialSmoothing ¶ added in v0.0.5
DoubleExponentialSmoothing applies double exponential smoothing to the DataList. The alpha parameter controls the level smoothing, and the beta parameter controls the trend smoothing. Returns a new DataList containing the smoothed values.
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 ¶
DropAll removes all occurrences of the specified values from the DataList. Supports multiple values to drop.
func (*DataList) DropIfContains ¶ added in v0.0.2
DropIfContains removes all elements from the DataList that contain the specified value.
func (*DataList) ExponentialSmoothing ¶ added in v0.0.5
ExponentialSmoothing applies exponential smoothing to the DataList. The alpha parameter controls the smoothing factor. Returns a new DataList containing the smoothed values.
func (*DataList) FillNaNWithMean ¶ added in v0.0.5
FillNaNWithMean replaces all NaN values in the DataList with the mean value. Directly modifies the DataList.
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 ¶
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 ¶
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 ¶
GMean calculates the geometric mean of the DataList. Returns the geometric mean. Returns math.NaN() if the DataList is empty or if no elements can be converted to float64.
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) HermiteInterpolation ¶ added in v0.0.5
HermiteInterpolation performs Hermite interpolation for the given x value using the DataList.
func (*DataList) IQR ¶
IQR calculates the interquartile range of the DataList. Returns math.NaN() if the DataList is empty or if Q1 or Q3 cannot be calculated. Returns the interquartile range (Q3 - Q1) as a float64.
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) IsEqualTo ¶ added in v0.0.12
IsEqualTo checks if the data of the DataList is equal to another DataList.
func (*DataList) IsTheSameAs ¶ added in v0.0.12
IsTheSameAs checks if the DataList is fully the same as another DataList. It checks for equality in name, data, creation timestamp, and last modified timestamp.
func (*DataList) LagrangeInterpolation ¶ added in v0.0.5
LagrangeInterpolation performs Lagrange interpolation for the given x value using the DataList.
func (*DataList) LinearInterpolation ¶ added in v0.0.5
LinearInterpolation performs linear interpolation for the given x value using the DataList.
func (*DataList) MAD ¶ added in v0.0.5
MAD calculates the mean absolute deviation of the DataList. Returns math.NaN() if the DataList is empty or if no valid elements can be used.
func (*DataList) Map ¶ added in v0.2.0
Map applies a function to all elements in the DataList and returns a new DataList with the results. The mapFunc should take an element of any type and its index, then return a transformed value of any type.
func (*DataList) Max ¶
Max returns the maximum value in the DataList. Returns math.NaN() if the DataList is empty or if no elements can be converted to float64.
func (*DataList) Mean ¶
Mean calculates the arithmetic mean of the DataList. Returns math.NaN() if the DataList is empty or if no elements can be converted to float64.
func (*DataList) Median ¶
Median calculates the median of the DataList. Returns math.NaN() if the DataList is empty or if no valid elements can be used.
func (*DataList) Min ¶
Min returns the minimum value in the DataList. Returns math.NaN() if the DataList is empty or if no elements can be converted to float64.
func (*DataList) Mode ¶
Mode calculates the mode of the DataList. Only works with numeric data types. Mode could be a single value or multiple values. Returns nil if the DataList is empty or if no valid elements can be used.
func (*DataList) MovingAverage ¶ added in v0.0.5
MovingAverage calculates the moving average of the DataList using a specified window size. Returns a new DataList containing the moving average values.
func (*DataList) MovingStdev ¶ added in v0.0.5
MovingStdDev calculates the moving standard deviation for the DataList using a specified window size.
func (*DataList) NearestNeighborInterpolation ¶ added in v0.0.5
NearestNeighborInterpolation performs nearest-neighbor interpolation for the given x value using the DataList.
func (*DataList) NewtonInterpolation ¶ added in v0.0.5
NewtonInterpolation performs Newton's interpolation for the given x value using the DataList.
func (*DataList) Normalize ¶ added in v0.0.5
Normalize normalizes the data in the DataList, skipping NaN values. Directly modifies the DataList.
func (*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 ¶
ParseStrings converts all elements in the DataList to strings.
func (*DataList) Percentile ¶
Percentile calculates the percentile based on the input value (0 to 100).
func (*DataList) Pop ¶
Pop removes and returns the last element from the DataList. Returns the last element. Returns nil if the DataList is empty.
func (*DataList) QuadraticInterpolation ¶ added in v0.0.5
QuadraticInterpolation performs quadratic interpolation for the given x value using the DataList.
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). This implementation uses percentiles to compute quartiles.
func (*DataList) Range ¶
Range calculates the range of the DataList. Returns math.NaN() if the DataList is empty or if Max or Min cannot be calculated.
func (*DataList) ReplaceAll ¶
ReplaceAll replaces all occurrences of oldValue with newValue in the DataList. If oldValue is not found, no changes are made.
func (*DataList) ReplaceFirst ¶
ReplaceFirst replaces the first occurrence of oldValue with newValue.
func (*DataList) ReplaceLast ¶
ReplaceLast replaces the last occurrence of oldValue with newValue.
func (*DataList) ReplaceOutliers ¶ added in v0.0.5
ReplaceOutliers replaces outliers in the DataList with the specified replacement value (e.g., mean, median).
func (*DataList) Show ¶ added in v0.2.0
func (dl *DataList) Show()
Show displays the content of DataList in a clean linear format. It adapts to terminal width and always displays in a linear format, not as a table. For more control over which items to display, use ShowRange.
func (*DataList) ShowRange ¶ added in v0.2.0
ShowRange displays the content of DataList within a specified range in a clean linear format. It adapts to terminal width and always displays in a linear format, not as a table. startEnd is an optional parameter that can be [start, end] to specify the range of items to display. if startEnd is not provided, all items will be displayed. if only one value is provided, there are two behaviors: - if positive, it shows the first N items (e.g., ShowRange(5) shows first 5 items) - if negative, it shows the last N items (e.g., ShowRange(-5) shows last 5 items) For two parameters [start, end], it shows items from index start (inclusive) to index end (exclusive). If end is nil, it shows items from index start to the end of the list. Example: dl.ShowRange() - shows all items Example: dl.ShowRange(5) - shows the first 5 items Example: dl.ShowRange(-5) - shows the last 5 items Example: dl.ShowRange(2, 10) - shows items with indices 2 to 9 (not including 10) Example: dl.ShowRange(2, -1) - shows items from index 2 to the end of the list Example: dl.ShowRange(2, nil) - shows items from index 2 to the end of the list
func (*DataList) ShowTypes ¶ added in v0.2.0
func (dl *DataList) ShowTypes()
ShowTypes displays the data types of each element in the DataList. It adapts to terminal width and always displays in a linear format.
func (*DataList) ShowTypesRange ¶ added in v0.2.0
ShowTypesRange displays the data types of DataList within a specified range. startEnd 参数同 ShowRange。
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) Standardize ¶ added in v0.0.5
Standardize standardizes the data in the DataList. Directly modifies the DataList.
func (*DataList) Stdev ¶
Stdev calculates the standard deviation (sample) of the DataList. Returns math.NaN() if the DataList is empty or if no valid elements can be used.
func (*DataList) StdevP ¶
StdevP calculates the standard deviation (population) of the DataList. Returns math.NaN() if the DataList is empty or if no valid elements can be used.
func (*DataList) Sum ¶ added in v0.0.1
Sum calculates the sum of all elements in the DataList. Returns math.NaN() if the DataList is empty or if no elements can be converted to float64.
func (*DataList) Summary ¶ added in v0.2.0
func (dl *DataList) Summary()
Summary displays a comprehensive statistical summary of the DataList directly to the console.
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) Var ¶
Var calculates the variance (sample variance) of the DataList. Returns math.NaN() if the DataList is empty or if not enough valid elements are available.
func (*DataList) VarP ¶
VarP calculates the variance (population variance) of the DataList. Returns math.NaN() if the DataList is empty or if no valid elements can be used.
func (*DataList) WeightedMean ¶ added in v0.0.5
WeightedMean calculates the weighted mean of the DataList using the provided weights. The weights parameter should be a slice or a DataList of the same length as the DataList. Returns math.NaN() if the DataList is empty, weights are invalid, or if no valid elements can be used.
func (*DataList) WeightedMovingAverage ¶ added in v0.0.5
WeightedMovingAverage applies a weighted moving average to the DataList with a given window size. The weights parameter should be a slice or a DataList of the same length as the window size. Returns a new DataList containing the weighted moving average values.
type DataTable ¶ added in v0.0.1
type DataTable struct {
// contains filtered or unexported fields
}
DataTable is the core data structure of Insyra for handling structured data. It provides rich data manipulation functionality including reading, writing, filtering, statistical analysis, and transformation operations.
DataTable uses a columnar storage format where each column is represented by a DataList. It supports both alphabetical column indexing (A, B, C...) and named columns, as well as row naming capabilities.
Key features: - Thread-safe operations via AtomicDo - Flexible data types using interface{} - Column and row indexing/naming - Comprehensive data manipulation methods - CSV/JSON/SQL import/export capabilities
func NewDataTable ¶ added in v0.0.1
func ReadCSV ¶ added in v0.2.4
func ReadCSV(filePath string, setFirstColToRowNames bool, setFirstRowToColNames bool) (*DataTable, error)
ReadCSV loads a CSV file into a DataTable, with options to set the first column as row names and the first row as column names.
func ReadCSV_String ¶ added in v0.2.4
func ReadJSON ¶ added in v0.2.4
ReadJSON reads a JSON file and loads the data into a DataTable and returns it.
func ReadJSON_Bytes ¶ added in v0.2.4
func ReadSQL ¶ added in v0.2.0
ReadSQL reads table data from the database and converts it into a DataTable object. If a custom Query is provided in options, it will use the custom query. Otherwise, it uses tableName and other options to construct the SQL query.
func Slice2DToDataTable ¶ added in v0.2.7
Slice2DToDataTable converts a 2D slice of any type into a DataTable. It supports various 2D array types such as [][]any, [][]int, [][]float64, [][]string, etc.
func (*DataTable) AddColUsingCCL ¶ added in v0.2.2
func (*DataTable) AppendCols ¶ added in v0.0.14
AppendCols appends columns to the DataTable, with each column represented by a DataList. If the columns are shorter than the existing columns, nil values will be appended to match the length. If the columns are longer than the existing columns, the existing columns will be extended with nil values.
func (*DataTable) AppendRowsByColIndex ¶ added in v0.0.14
AppendRowsByIndex appends rows to the DataTable, with each row represented by a map of column index and value. If the rows are shorter than the existing columns, nil values will be appended to match the length. If the rows are longer than the existing columns, the existing columns will be extended with nil values.
func (*DataTable) AppendRowsByColName ¶ added in v0.0.14
AppendRowsByName appends rows to the DataTable, with each row represented by a map of column name and value. If the rows are shorter than the existing columns, nil values will be appended to match the length. If the rows are longer than the existing columns, the existing columns will be extended with nil values.
func (*DataTable) AppendRowsFromDataList ¶ added in v0.0.1
AppendRowsFromDataList appends rows to the DataTable, with each row represented by a DataList. If the rows are shorter than the existing columns, nil values will be appended to match the length. If the rows are longer than the existing columns, the existing columns will be extended with nil values.
func (*DataTable) ChangeColName ¶ added in v0.2.2
func (*DataTable) ChangeRowName ¶ added in v0.2.2
func (*DataTable) Clone ¶ added in v0.2.5
Clone creates a deep copy of the DataTable. It copies all columns, column indices, row names, and metadata, ensuring that modifications to the original DataTable do not affect the clone. The cloned DataTable has a new creation timestamp and is fully independent.
func (*DataTable) ColNamesToFirstRow ¶ added in v0.2.4
func (*DataTable) Count ¶ added in v0.0.4
Count returns the number of occurrences of the given value in the DataTable.
func (*DataTable) Counter ¶ added in v0.0.14
Counter returns the number of occurrences of the given value in the DataTable. Return a map[any]int
func (*DataTable) DropColNames ¶ added in v0.2.4
func (*DataTable) DropColsByIndex ¶ added in v0.0.14
DropColsByIndex drops columns by their index names.
func (*DataTable) DropColsByName ¶ added in v0.0.14
DropColsByName drops columns by their names.
func (*DataTable) DropColsByNumber ¶ added in v0.0.14
DropColsByNumber drops columns by their number.
func (*DataTable) DropColsContain ¶ added in v0.2.6
DropColsContain drops columns that contain the specified value.
func (*DataTable) DropColsContainExcelNA ¶ added in v0.2.6
func (dt *DataTable) DropColsContainExcelNA()
DropColsContainExcelNA drops columns that contain Excel NA values ("#N/A").
func (*DataTable) DropColsContainNil ¶ added in v0.0.14
func (dt *DataTable) DropColsContainNil()
DropColsContainNil drops columns that contain nil elements.
func (*DataTable) DropColsContainNumbers ¶ added in v0.0.14
func (dt *DataTable) DropColsContainNumbers()
DropColsContainNumbers drops columns that contain number elements.
func (*DataTable) DropColsContainStringElements ¶ added in v0.0.14
func (dt *DataTable) DropColsContainStringElements()
DropColsContainStringElements drops columns that contain string elements.
func (*DataTable) DropRowNames ¶ added in v0.2.4
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) DropRowsContain ¶ added in v0.2.6
DropRowsContain drops rows that contain the specified value.
func (*DataTable) DropRowsContainExcelNA ¶ added in v0.2.6
func (dt *DataTable) DropRowsContainExcelNA()
DropRowsContainExcelNA drops rows that contain Excel NA values ("#N/A").
func (*DataTable) DropRowsContainNil ¶ added in v0.0.2
func (dt *DataTable) DropRowsContainNil()
DropRowsContainNil drops rows that contain nil elements.
func (*DataTable) DropRowsContainNumbers ¶ added in v0.0.2
func (dt *DataTable) DropRowsContainNumbers()
DropRowsContainNumbers drops rows that contain number elements.
func (*DataTable) DropRowsContainStringElements ¶ added in v0.0.2
func (dt *DataTable) DropRowsContainStringElements()
DropRowsContainStringElements drops rows that contain string elements.
func (*DataTable) Filter ¶ added in v0.0.2
func (dt *DataTable) Filter(filterFunc FilterFunc) *DataTable
Filter applies a custom filter function to the DataTable and returns the filtered DataTable.
func (*DataTable) FilterByColIndexEqualTo ¶ added in v0.0.14
FilterByColIndexEqualTo filters to only keep the column with the specified index.
func (*DataTable) FilterByColIndexGreaterThan ¶ added in v0.0.14
FilterByColIndexGreaterThan filters columns with index greater than the specified column.
func (*DataTable) FilterByColIndexGreaterThanOrEqualTo ¶ added in v0.0.14
FilterByColIndexGreaterThanOrEqualTo filters columns with index greater than or equal to the specified column.
func (*DataTable) FilterByColIndexLessThan ¶ added in v0.0.14
FilterByColIndexLessThan filters columns with index less than the specified column.
func (*DataTable) FilterByColIndexLessThanOrEqualTo ¶ added in v0.0.14
FilterByColIndexLessThanOrEqualTo filters columns with index less than or equal to the specified column.
func (*DataTable) FilterByColNameContains ¶ added in v0.0.14
FilterByColNameContains filters columns whose name contains the specified substring.
func (*DataTable) FilterByColNameEqualTo ¶ added in v0.0.14
FilterByColNameEqualTo filters to only keep the column with the specified name.
func (*DataTable) FilterByCustomElement ¶ added in v0.0.2
FilterByCustomElement filters the table based on a custom function applied to each element.
func (*DataTable) FilterByRowIndexEqualTo ¶ added in v0.0.2
FilterByRowIndexEqualTo filters to only keep the row with the specified index.
func (*DataTable) FilterByRowIndexGreaterThan ¶ added in v0.0.2
FilterByRowIndexGreaterThan filters rows with index greater than the specified threshold.
func (*DataTable) FilterByRowIndexGreaterThanOrEqualTo ¶ added in v0.0.2
FilterByRowIndexGreaterThanOrEqualTo filters rows with index greater than or equal to the specified threshold.
func (*DataTable) FilterByRowIndexLessThan ¶ added in v0.0.2
FilterByRowIndexLessThan filters rows with index less than the specified threshold.
func (*DataTable) FilterByRowIndexLessThanOrEqualTo ¶ added in v0.0.2
FilterByRowIndexLessThanOrEqualTo filters rows with index less than or equal to the specified threshold.
func (*DataTable) FilterByRowNameContains ¶ added in v0.0.2
FilterByRowNameContains filters rows whose name contains the specified substring.
func (*DataTable) FilterByRowNameEqualTo ¶ added in v0.0.2
FilterByRowNameEqualTo filters to only keep the row with the specified name.
func (*DataTable) FindColsIfAllElementsContainSubstring ¶ added in v0.0.14
FindColsIfAllElementsContainSubstring returns the indices of columns that contain all elements that contain the given substring.
func (*DataTable) FindColsIfAnyElementContainsSubstring ¶ added in v0.0.14
FindColsIfAnyElementContainsSubstring returns the indices of columns that contain at least one element that contains the given substring.
func (*DataTable) FindColsIfContains ¶ added in v0.0.14
FindColsIfContains returns the indices of columns that contain the given element.
func (*DataTable) FindColsIfContainsAll ¶ added in v0.0.14
FindColsIfContainsAll returns the indices of columns that contain all the given elements.
func (*DataTable) FindRowsIfAllElementsContainSubstring ¶ added in v0.0.2
FindRowsIfAllElementsContainSubstring returns the indices of rows that contain all elements that contain the given substring.
func (*DataTable) FindRowsIfAnyElementContainsSubstring ¶ added in v0.0.2
FindRowsIfAnyElementContainsSubstring returns the indices of rows that contain at least one element that contains the given substring.
func (*DataTable) FindRowsIfContains ¶ added in v0.0.2
FindRowsIfContains returns the indices of rows that contain the given element.
func (*DataTable) FindRowsIfContainsAll ¶ added in v0.0.2
FindRowsIfContainsAll returns the indices of rows that contain all the given elements.
func (*DataTable) GetCol ¶ added in v0.0.14
GetCol returns a new DataList containing the data of the column with the given index.
func (*DataTable) GetColByName ¶ added in v0.2.2
func (*DataTable) GetColByNumber ¶ added in v0.0.14
func (*DataTable) GetColIndexByName ¶ added in v0.2.4
GetColIndexByName returns the column index (A, B, C, ...) by its name.
func (*DataTable) GetColIndexByNumber ¶ added in v0.2.4
GetColIndexByNumber returns the column index (A, B, C, ...) by its number (0, 1, 2, ...).
func (*DataTable) GetColNameByIndex ¶ added in v0.2.4
GetColNameByIndex gets the column name by its Excel-style index (A, B, C, ..., Z, AA, AB, ...).
func (*DataTable) GetColNameByNumber ¶ added in v0.2.2
func (*DataTable) GetColNumberByName ¶ added in v0.2.4
func (*DataTable) GetCreationTimestamp ¶ added in v0.0.1
func (*DataTable) GetElement ¶ added in v0.0.2
GetElement returns the element at the given row and column index.
func (*DataTable) GetElementByNumberIndex ¶ added in v0.0.7
func (*DataTable) GetLastModifiedTimestamp ¶ added in v0.0.1
func (*DataTable) GetRow ¶ added in v0.0.2
GetRow returns a new DataList containing the data of the row with the given index.
func (*DataTable) GetRowByName ¶ added in v0.2.2
func (*DataTable) GetRowNameByIndex ¶ added in v0.0.2
GetRowNameByIndex returns the name of the row at the given index.
func (*DataTable) Headers ¶ added in v0.2.5
Headers is an alias for ColNames, returning the column names of the DataTable.
func (*DataTable) Map ¶ added in v0.2.0
Map applies a function to all elements in the DataTable and returns a new DataTable with the results. The mapFunc should take three parameters: row index (int), column index (string), and element (any), then return a transformed value of any type.
func (*DataTable) RowNamesToFirstCol ¶ added in v0.2.4
RowNamesToFirstCol moves the row names to the first column of the DataTable.
func (*DataTable) SetColNameByIndex ¶ added in v0.2.2
func (*DataTable) SetColNameByNumber ¶ added in v0.2.2
func (*DataTable) SetColNames ¶ added in v0.2.5
func (*DataTable) SetColToRowNames ¶ added in v0.0.14
SetColToRowNames sets the row names to the values of the specified column and drops the column.
func (*DataTable) SetHeaders ¶ added in v0.2.5
SetHeaders is an alias for SetColNames, setting the column names of the DataTable.
func (*DataTable) SetRowNameByIndex ¶ added in v0.0.2
func (*DataTable) SetRowNames ¶ added in v0.2.5
SetRowNames sets the row names of the DataTable. Different from SetColNames, it only sets names for existing rows.
func (*DataTable) SetRowToColNames ¶ added in v0.0.14
SetRowToColNames sets the column names to the values of the specified row and drops the row.
func (*DataTable) Show ¶ added in v0.0.1
func (dt *DataTable) Show()
Show displays the content of the DataTable in a formatted way. For more control over which rows to display, use ShowRange.
func (*DataTable) ShowRange ¶ added in v0.2.0
ShowRange displays the DataTable with a specified range of rows. startEnd is an optional parameter that can be [start, end] to specify the range of rows to display. if startEnd is not provided, all rows will be displayed. if only one value is provided, there are two behaviors: - if positive, it shows the first N rows (e.g., ShowRange(5) shows first 5 rows) - if negative, it shows the last N rows (e.g., ShowRange(-5) shows last 5 rows) For two parameters [start, end], it shows rows from index start (inclusive) to index end (exclusive). If end is nil, it shows rows from index start to the end of the table. Example: dt.ShowRange() - shows all rows Example: dt.ShowRange(5) - shows the first 5 rows Example: dt.ShowRange(-5) - shows the last 5 rows Example: dt.ShowRange(2, 10) - shows rows with indices 2 to 9 (not including 10) Example: dt.ShowRange(2, nil) - shows rows from index 2 to the end of the table
func (*DataTable) ShowTypes ¶ added in v0.0.3
func (dt *DataTable) ShowTypes()
ShowTypes displays the data types of each element in the DataTable. For more control over which rows to display, use ShowTypesRange.
func (*DataTable) ShowTypesRange ¶ added in v0.2.0
ShowTypesRange displays the data types of each element in the DataTable within a specified range of rows. startEnd is an optional parameter that can be [start, end] to specify the range of rows to display. if startEnd is not provided, all rows will be displayed. if only one value is provided, there are two behaviors: - if positive, it shows the first N rows (e.g., ShowTypesRange(5) shows first 5 rows) - if negative, it shows the last N rows (e.g., ShowTypesRange(-5) shows last 5 rows) For two parameters [start, end], it shows rows from index start (inclusive) to index end (exclusive). If end is nil, it shows rows from index start to the end of the table. Example: dt.ShowTypesRange() - shows all rows Example: dt.ShowTypesRange(5) - shows the first 5 rows Example: dt.ShowTypesRange(-5) - shows the last 5 rows Example: dt.ShowTypesRange(2, 10) - shows rows with indices 2 to 9 (not including 10) Example: dt.ShowTypesRange(2, nil) - shows rows from index 2 to the end of the table
func (*DataTable) SimpleRandomSample ¶ added in v0.2.5
SimpleRandomSample returns a new DataTable containing a simple random sample of the specified size. If sampleSize is greater than the number of rows in the DataTable, it returns a copy of the original DataTable. If sampleSize is less than or equal to 0, it returns an empty DataTable.
func (*DataTable) Size ¶ added in v0.0.4
Size returns the number of rows and columns in the DataTable.
func (*DataTable) SortBy ¶ added in v0.2.5
func (dt *DataTable) SortBy(configs ...DataTableSortConfig) *DataTable
SortBy sorts the DataTable based on multiple columns as specified in the configs. Supports sorting by column index (A, B, ...), column number (0, 1, ...), or column name. For multi-column sorting, the order of configs determines the priority (first config has highest priority).
func (*DataTable) Summary ¶ added in v0.2.0
func (dt *DataTable) Summary()
Summary displays a comprehensive statistical summary of the DataTable directly to the console. It shows overall statistics for the entire table, including the number of rows and columns, and aggregate information about data types and values across the whole table. The output is formatted for easy reading with proper color coding.
func (*DataTable) SwapColsByIndex ¶ added in v0.2.2
SwapColsByIndex swaps two columns by their letter indices.
func (*DataTable) SwapColsByName ¶ added in v0.2.2
SwapColsByName swaps two columns by their names.
func (*DataTable) SwapColsByNumber ¶ added in v0.2.2
SwapColsByNumber swaps two columns by their numerical indices.
func (*DataTable) SwapRowsByIndex ¶ added in v0.2.2
SwapRowsByIndex swaps two rows by their numerical indices.
func (*DataTable) SwapRowsByName ¶ added in v0.2.2
SwapRowsByName swaps two rows by their names.
func (*DataTable) To2DSlice ¶ added in v0.2.7
To2DSlice converts the DataTable to a 2D slice of any. Each row in the DataTable becomes a slice in the outer slice, and each column's element at that row becomes an element in the inner slice. If a column is shorter than the maximum row count, nil values are used to fill.
func (*DataTable) ToCSV ¶ added in v0.0.3
func (dt *DataTable) ToCSV(filePath string, setRowNamesToFirstCol bool, setColNamesToFirstRow bool, includeBOM bool) error
ToCSV converts the DataTable to CSV format and writes it to the provided file path. The function accepts two parameters: - filePath: the file path to write the CSV file to - setRowNamesToFirstCol: if true, the first column will be used as row names - setColNamesToFirstRow: if true, the first row will be used as column names
func (*DataTable) ToJSON ¶ added in v0.1.5
ToJSON converts the DataTable to JSON format and writes it to the provided file path. The function accepts two parameters: - filePath: the file path to write the JSON file to. - useColName: if true, the column names will be used as keys in the JSON object, otherwise the column index(A, B, C...) will be used. Every row will be a JSON object with the column names as keys and the row values as values. The function returns an error if the file cannot be created or the JSON data cannot be written to the file.
func (*DataTable) ToJSON_Bytes ¶ added in v0.1.5
ToJSON_Byte converts the DataTable to JSON format and returns it as a byte slice. The function accepts one parameter: - useColName: if true, the column names will be used as keys in the JSON object, otherwise the column index(A, B, C...) will be used. Every row will be a JSON object with the column names as keys and the row values as values. The function returns the JSON data as a byte slice.
func (*DataTable) Transpose ¶ added in v0.0.8
Transpose transposes the DataTable, converting rows into columns and vice versa.
func (*DataTable) UpdateColByNumber ¶ added in v0.0.14
UpdateColByNumber updates the column at the given index.
func (*DataTable) UpdateElement ¶ added in v0.0.2
UpdateElement updates the element at the given row and column index.
type DataTableSortConfig ¶ added in v0.2.5
type DataTableSortConfig struct {
ColumnIndex string // The column index (A, B, C, ...) of the column to sort by, highest priority
ColumnNumber int // The column number (0, 1, 2, ...) of the column to sort by, lowest priority
ColumnName string // The column name of the column to sort by, second priority
Descending bool // Whether to sort in descending order, default is ascending
}
type ErrPoppingMode ¶ added in v0.2.2
type ErrPoppingMode int
const ( // ErrPoppingModeFIFO retrieves the first error in the slice. ErrPoppingModeFIFO ErrPoppingMode = iota // ErrPoppingModeLIFO retrieves the last error in the slice. ErrPoppingModeLIFO )
ErrPoppingMode defines the mode for popping errors.
type FilterFunc ¶ added in v0.0.2
FilterFunc is a custom filter function that takes the row index, column name, and value as input and returns a boolean.
type IDataList ¶
type IDataList interface {
AtomicDo(func(*DataList))
GetCreationTimestamp() int64
GetLastModifiedTimestamp() int64
GetName() string
SetName(string) *DataList
Data() []any
Append(values ...any)
Get(index int) any
Clone() *DataList
Count(value any) int
Counter() map[any]int
Update(index int, value any)
InsertAt(index int, value any)
FindFirst(any) any
FindLast(any) any
FindAll(any) []int
Filter(func(any) bool) *DataList
ReplaceFirst(any, any)
ReplaceLast(any, any)
ReplaceAll(any, any)
ReplaceOutliers(float64, float64) *DataList
Pop() any
Drop(index int) *DataList
DropAll(...any) *DataList
DropIfContains(any) *DataList
Clear() *DataList
ClearStrings() *DataList
ClearNumbers() *DataList
ClearNaNs() *DataList
ClearOutliers(float64) *DataList
Normalize() *DataList
Standardize() *DataList
FillNaNWithMean() *DataList
MovingAverage(int) *DataList
WeightedMovingAverage(int, any) *DataList
ExponentialSmoothing(float64) *DataList
DoubleExponentialSmoothing(float64, float64) *DataList
MovingStdev(int) *DataList
Len() int
Sort(ascending ...bool) *DataList
Map(mapFunc func(int, any) any) *DataList
Rank() *DataList
Reverse() *DataList
Upper() *DataList
Lower() *DataList
Capitalize() *DataList // Statistics
Sum() float64
Max() float64
Min() float64
Mean() float64
WeightedMean(weights any) float64
GMean() float64
Median() float64
Mode() []float64
MAD() float64
Stdev() float64
StdevP() float64
Var() float64
VarP() float64
Range() float64
Quartile(int) float64
IQR() float64
Percentile(float64) float64
Difference() *DataList
Summary()
// comparison
IsEqualTo(*DataList) bool
IsTheSameAs(*DataList) bool
Show()
ShowRange(startEnd ...any)
ShowTypes()
ShowTypesRange(startEnd ...any)
// conversion
ParseNumbers() *DataList
ParseStrings() *DataList
ToF64Slice() []float64
ToStringSlice() []string
// Interpolation
LinearInterpolation(float64) float64
QuadraticInterpolation(float64) float64
LagrangeInterpolation(float64) float64
NearestNeighborInterpolation(float64) float64
NewtonInterpolation(float64) float64
HermiteInterpolation(float64, []float64) float64
// contains filtered or unexported methods
}
IDataList defines the behavior expected from a DataList.
type IDataTable ¶ added in v0.0.1
type IDataTable interface {
AtomicDo(func(*DataTable))
AppendCols(columns ...*DataList) *DataTable
AppendRowsFromDataList(rowsData ...*DataList) *DataTable
AppendRowsByColIndex(rowsData ...map[string]any) *DataTable
AppendRowsByColName(rowsData ...map[string]any) *DataTable
GetElement(rowIndex int, columnIndex string) any
GetElementByNumberIndex(rowIndex int, columnIndex int) any
GetCol(index string) *DataList
GetColByNumber(index int) *DataList
GetColByName(name string) *DataList
GetRow(index int) *DataList
GetRowByName(name string) *DataList
UpdateElement(rowIndex int, columnIndex string, value any)
UpdateCol(index string, dl *DataList)
UpdateColByNumber(index int, dl *DataList)
UpdateRow(index int, dl *DataList)
SetColToRowNames(columnIndex string) *DataTable
SetRowToColNames(rowIndex int) *DataTable
ChangeColName(oldName, newName string) *DataTable
GetColNameByNumber(index int) string
GetColIndexByName(name string) string
GetColIndexByNumber(number int) string
GetColNumberByName(name string) int
SetColNameByIndex(index string, name string) *DataTable
SetColNameByNumber(numberIndex int, name string) *DataTable
ColNamesToFirstRow() *DataTable
DropColNames() *DataTable
ColNames() []string
Headers() []string
SetColNames(colNames []string) *DataTable
SetHeaders(headers []string) *DataTable
FindRowsIfContains(value any) []int
FindRowsIfContainsAll(values ...any) []int
FindRowsIfAnyElementContainsSubstring(substring string) []int
FindRowsIfAllElementsContainSubstring(substring string) []int
FindColsIfContains(value any) []string
FindColsIfContainsAll(values ...any) []string
FindColsIfAnyElementContainsSubstring(substring string) []string
FindColsIfAllElementsContainSubstring(substring string) []string
DropColsByName(columnNames ...string)
DropColsByIndex(columnIndices ...string)
DropColsByNumber(columnIndices ...int)
DropColsContainStringElements()
DropColsContainNumbers()
DropColsContainNil()
DropColsContain(value ...any)
DropColsContainExcelNA()
DropRowsByIndex(rowIndices ...int)
DropRowsByName(rowNames ...string)
DropRowsContainStringElements()
DropRowsContainNumbers()
DropRowsContainNil()
DropRowsContain(value ...any)
DropRowsContainExcelNA()
Data(useNamesAsKeys ...bool) map[string][]any
Show()
ShowTypes()
ShowRange(startEnd ...any)
ShowTypesRange(startEnd ...any)
GetRowNameByIndex(index int) string
SetRowNameByIndex(index int, name string)
ChangeRowName(oldName, newName string) *DataTable
RowNamesToFirstCol() *DataTable
DropRowNames() *DataTable
RowNames() []string
SetRowNames(rowNames []string) *DataTable
GetCreationTimestamp() int64
GetLastModifiedTimestamp() int64
// name
GetName() string
SetName(name string) *DataTable
// Statistics
Size() (numRows int, numCols int)
Count(value any) int
Mean() any
Summary()
// Operations
Transpose() *DataTable
Clone() *DataTable
To2DSlice() [][]any
SimpleRandomSample(sampleSize int) *DataTable
Map(mapFunc func(rowIndex int, colIndex string, element any) any) *DataTable
SortBy(configs ...DataTableSortConfig) *DataTable
// Filters
Filter(filterFunc FilterFunc) *DataTable
FilterByCustomElement(f func(value any) bool) *DataTable
FilterByColIndexGreaterThan(threshold string) *DataTable
FilterByColIndexGreaterThanOrEqualTo(threshold string) *DataTable
FilterByColIndexLessThan(threshold string) *DataTable
FilterByColIndexLessThanOrEqualTo(threshold string) *DataTable
FilterByColIndexEqualTo(index string) *DataTable
FilterByColNameEqualTo(name string) *DataTable
FilterByColNameContains(substring string) *DataTable
FilterByRowNameEqualTo(name string) *DataTable
FilterByRowNameContains(substring string) *DataTable
FilterByRowIndexGreaterThan(threshold int) *DataTable
FilterByRowIndexGreaterThanOrEqualTo(threshold int) *DataTable
FilterByRowIndexLessThan(threshold int) *DataTable
FilterByRowIndexLessThanOrEqualTo(threshold int) *DataTable
FilterByRowIndexEqualTo(index int) *DataTable
// Swap
SwapColsByName(columnName1 string, columnName2 string) *DataTable
SwapColsByIndex(columnIndex1 string, columnIndex2 string) *DataTable
SwapColsByNumber(columnNumber1 int, columnNumber2 int) *DataTable
SwapRowsByIndex(rowIndex1 int, rowIndex2 int) *DataTable
SwapRowsByName(rowName1 string, rowName2 string) *DataTable
// CSV
ToCSV(filePath string, setRowNamesToFirstCol bool, setColNamesToFirstRow bool, includeBOM bool) error
// JSON
ToJSON(filePath string, useColName bool) error
ToJSON_Bytes(useColName bool) []byte
ToSQL(db *gorm.DB, tableName string, options ...ToSQLOptions) error
AddColUsingCCL(newColName, ccl string) *DataTable
// contains filtered or unexported methods
}
IDataTable defines the behavior expected from a DataTable.
func ConvertLongDataToWide ¶ added in v0.0.8
func ConvertLongDataToWide(data, factor IDataList, independents []IDataList, aggFunc func([]float64) float64) IDataTable
ConvertLongDataToWide converts long data to wide data. data: 觀測值(依變數) factor: 因子 independents: 自變數 aggFunc: 聚合函數 Return DataTable.
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 )
func PopError ¶ added in v0.2.2
func PopError(mode ErrPoppingMode) (LogLevel, string)
PopError retrieves and removes the first error from the errorSlice. If the slice is empty, it returns an empty string and LogLevelInfo.
func PopErrorByFuncName ¶ added in v0.2.2
func PopErrorByFuncName(packageName, funcName string, mode ErrPoppingMode) (LogLevel, string)
func PopErrorByPackageName ¶ added in v0.2.2
func PopErrorByPackageName(packageName string, mode ErrPoppingMode) (LogLevel, string)
type ReadSQLOptions ¶ added in v0.2.0
type ReadSQLOptions struct {
RowNameColumn string // Specifies which column to use as row names, default is "row_name"
Query string // Custom SQL query, if provided, other options will be ignored
Limit int // Limit the number of rows to read
Offset int // Starting position for reading rows
WhereClause string // WHERE clause
OrderBy string // ORDER BY clause
}
type SQLActionIfTableExists ¶ added in v0.2.0
type SQLActionIfTableExists int
const ( FailIfExists SQLActionIfTableExists = iota ReplaceIfExists AppendIfExists )
type ToSQLOptions ¶ added in v0.2.0
type ToSQLOptions struct {
IfExists SQLActionIfTableExists // "fail", "replace", "append"
RowNames bool
ColumnTypes map[string]string // 自訂型別
}
Source Files
¶
- atomic.go
- ccl.go
- config.go
- datalist.go
- datalist_interpolation.go
- datalist_map.go
- datalist_summary.go
- datatable.go
- datatable_ccl.go
- datatable_colindex.go
- datatable_colname.go
- datatable_csv.go
- datatable_filters.go
- datatable_json.go
- datatable_map.go
- datatable_name.go
- datatable_rowname.go
- datatable_sampling.go
- datatable_sort.go
- datatable_summary.go
- datatable_swap.go
- datatable_to_sql.go
- error_buffer.go
- init.go
- interfaces.go
- logger.go
- read.go
- show.go
- utils.go
- version.go
Directories
¶
| Path | Synopsis |
|---|---|
|
`allpkgs` package imports all Insyra packages.
|
`allpkgs` package imports all Insyra packages. |
|
`csvxl` package provides functions for converting between CSV and Excel formats.
|
`csvxl` package provides functions for converting between CSV and Excel formats. |
|
`gplot` package provides functions for data visualization using gonum/plot.
|
`gplot` package provides functions for data visualization using gonum/plot. |
|
internal
|
|
|
`isr` package is the syntactic sugar of insyra.
|
`isr` package is the syntactic sugar of insyra. |
|
`lp` package provides linear programming functionalities using GLPK.
|
`lp` package provides linear programming functionalities using GLPK. |
|
`lpgen` package provides functions for generating linear programming models.
|
`lpgen` package provides functions for generating linear programming models. |
|
`mkt` package provides marketing-related data analysis functions.
|
`mkt` package provides marketing-related data analysis functions. |
|
`parallel` package provides functions for parallel processing.
|
`parallel` package provides functions for parallel processing. |
|
`plot` package provides functions for creating and manipulating plots.
|
`plot` package provides functions for creating and manipulating plots. |
|
`py` package provides functions for working with Python.
|
`py` package provides functions for working with Python. |
|
`stats` package provides functions for statistical analysis.
|
`stats` package provides functions for statistical analysis. |
|
internal/fa
fa/GPArotation_GPFoblq.go
|
fa/GPArotation_GPFoblq.go |
