Documentation
¶
Index ¶
- Variables
- func ConvertValue(value string, targetType ColumnType) (interface{}, error)
- func DetectDelimiter(filename string) (rune, error)
- func MustOperation(op string, fn func() error)
- func SafeOperation(op string, fn func() error) (err error)
- type CSVInfo
- type CSVOptions
- type ColumnType
- type DataFrame
- func NewDataFrame() *DataFrame
- func NewDataFrameFromMap(data map[string]interface{}) (*DataFrame, error)
- func NewDataFrameFromSeries(series ...*Series) (*DataFrame, error)
- func ReadCSV(filename string) (*DataFrame, error)
- func ReadCSVFromString(data string) (*DataFrame, error)
- func ReadCSVFromStringWithOptions(data string, options CSVOptions) (*DataFrame, error)
- func ReadCSVWithOptions(filename string, options CSVOptions) (*DataFrame, error)
- func (df *DataFrame) AddColumn(series *Series) *DataFrame
- func (df *DataFrame) Columns() []string
- func (df *DataFrame) Copy() *DataFrame
- func (df *DataFrame) Correlation() (*DataFrame, error)
- func (df *DataFrame) Count() int
- func (df *DataFrame) Describe() (*DataFrame, error)
- func (df *DataFrame) Drop(columns ...string) *DataFrame
- func (df *DataFrame) DropColumn(name string) *DataFrame
- func (df *DataFrame) Error() error
- func (df *DataFrame) Filter(column, operator string, value interface{}) *DataFrame
- func (df *DataFrame) Get(row int, column string) (interface{}, error)
- func (df *DataFrame) GetColumnType(name string) (ColumnType, error)
- func (df *DataFrame) GetSeries(name string) (*Series, error)
- func (df *DataFrame) GroupBy(columns ...string) *GroupBy
- func (df *DataFrame) HasColumn(name string) bool
- func (df *DataFrame) Head(n int) *DataFrame
- func (df *DataFrame) Info() string
- func (df *DataFrame) IsEmpty() bool
- func (df *DataFrame) Len() int
- func (df *DataFrame) Max(column string) (interface{}, error)
- func (df *DataFrame) Mean(column string) (float64, error)
- func (df *DataFrame) Median(column string) (float64, error)
- func (df *DataFrame) Min(column string) (interface{}, error)
- func (df *DataFrame) NumericSummary(column string) (*NumericStats, error)
- func (df *DataFrame) Quantile(column string, q float64) (float64, error)
- func (df *DataFrame) Query(query string) *DataFrame
- func (df *DataFrame) RenameColumn(oldName, newName string) *DataFrame
- func (df *DataFrame) ResetIndex() *DataFrame
- func (df *DataFrame) Select(columns ...string) *DataFrame
- func (df *DataFrame) Set(row int, column string, value interface{}) error
- func (df *DataFrame) Shape() (int, int)
- func (df *DataFrame) Sort(column string, ascending bool) *DataFrame
- func (df *DataFrame) SortBy(columns []string, ascending []bool) *DataFrame
- func (df *DataFrame) Std(column string) (float64, error)
- func (df *DataFrame) String() string
- func (df *DataFrame) Sum(column string) (float64, error)
- func (df *DataFrame) Tail(n int) *DataFrame
- func (df *DataFrame) Unique(column string) ([]interface{}, error)
- func (df *DataFrame) ValueCounts(column string) (*DataFrame, error)
- func (df *DataFrame) Var(column string) (float64, error)
- func (df *DataFrame) Where(column, operator string, value interface{}) *DataFrame
- func (df *DataFrame) Width() int
- func (df *DataFrame) WriteCSV(filename string) error
- func (df *DataFrame) WriteCSVWithOptions(filename string, options CSVOptions) error
- type GroupBy
- type NumericStats
- type OtterError
- type Series
Constants ¶
This section is empty.
Variables ¶
var ErrColumnNotFound = &OtterError{
Op: "ColumnAccess",
Message: "column not found",
Row: -1,
}
ErrColumnNotFound is returned when a requested column doesn't exist
var ErrEmptyDataFrame = &OtterError{
Op: "Operation",
Message: "cannot operate on empty DataFrame",
Row: -1,
}
ErrEmptyDataFrame is returned when operating on an empty DataFrame
var ErrIndexOutOfRange = &OtterError{
Op: "IndexAccess",
Message: "index out of range",
Row: -1,
}
ErrIndexOutOfRange is returned when accessing an invalid row index
var ErrInvalidOperation = &OtterError{
Op: "Operation",
Message: "invalid operation",
Row: -1,
}
ErrInvalidOperation is returned for invalid operations
var ErrTypeMismatch = &OtterError{
Op: "TypeConversion",
Message: "type mismatch",
Row: -1,
}
ErrTypeMismatch is returned when there's a type conversion error
Functions ¶
func ConvertValue ¶
func ConvertValue(value string, targetType ColumnType) (interface{}, error)
ConvertValue converts a string value to the specified type
func DetectDelimiter ¶
DetectDelimiter attempts to detect the delimiter used in a CSV file
func MustOperation ¶
MustOperation executes an operation and panics if it fails (for testing/debugging)
func SafeOperation ¶
SafeOperation wraps a function to handle panics and convert them to errors
Types ¶
type CSVInfo ¶
CSVInfo contains information about a CSV file
func ValidateCSV ¶
ValidateCSV checks if a CSV file is valid and returns basic info
type CSVOptions ¶
type CSVOptions struct {
HasHeader bool // Whether the first row contains headers
Delimiter rune // Field delimiter (default: ',')
SkipRows int // Number of rows to skip at the beginning
MaxRows int // Maximum number of rows to read (0 = unlimited)
}
CSVOptions provides options for CSV reading/writing
type ColumnType ¶
type ColumnType int
ColumnType represents the data type of a column
const ( StringType ColumnType = iota Int64Type Float64Type BoolType TimeType )
func InferType ¶
func InferType(values []string) ColumnType
InferType attempts to infer the best type for a slice of string values
func (ColumnType) String ¶
func (ct ColumnType) String() string
String returns the string representation of a ColumnType
type DataFrame ¶
type DataFrame struct {
// contains filtered or unexported fields
}
DataFrame represents a collection of Series with aligned indices
func NewDataFrameFromMap ¶
NewDataFrameFromMap creates a DataFrame from a map of column data
func NewDataFrameFromSeries ¶
NewDataFrameFromSeries creates a DataFrame from a collection of Series
func ReadCSVFromString ¶
ReadCSVFromString reads CSV data from a string
func ReadCSVFromStringWithOptions ¶
func ReadCSVFromStringWithOptions(data string, options CSVOptions) (*DataFrame, error)
ReadCSVFromStringWithOptions reads CSV data from a string with options
func ReadCSVWithOptions ¶
func ReadCSVWithOptions(filename string, options CSVOptions) (*DataFrame, error)
ReadCSVWithOptions reads a CSV file with custom options
func (*DataFrame) Correlation ¶
Correlation calculates correlation matrix for numeric columns
func (*DataFrame) Describe ¶
Describe generates summary statistics for all numeric columns (like Pandas describe())
func (*DataFrame) DropColumn ¶
DropColumn removes a column from the DataFrame
func (*DataFrame) GetColumnType ¶
func (df *DataFrame) GetColumnType(name string) (ColumnType, error)
GetColumnType returns the type of the specified column
func (*DataFrame) NumericSummary ¶
func (df *DataFrame) NumericSummary(column string) (*NumericStats, error)
NumericSummary provides a quick summary of a numeric column
func (*DataFrame) RenameColumn ¶
RenameColumn renames a column in the DataFrame
func (*DataFrame) ResetIndex ¶
Reset index (currently a no-op, but maintains Pandas compatibility)
func (*DataFrame) ValueCounts ¶
ValueCounts returns the frequency of each unique value in a column
func (*DataFrame) WriteCSVWithOptions ¶
func (df *DataFrame) WriteCSVWithOptions(filename string, options CSVOptions) error
WriteCSVWithOptions writes a DataFrame to CSV with custom options
type GroupBy ¶
type GroupBy struct {
// contains filtered or unexported fields
}
GroupBy represents a grouped DataFrame for aggregation operations
type NumericStats ¶
type NumericStats struct {
Column string
Count int
Sum float64
Mean float64
Min float64
Max float64
Std float64
Median float64
}
NumericStats holds summary statistics for a numeric column
func (*NumericStats) String ¶
func (ns *NumericStats) String() string
String returns a formatted string representation of NumericStats
type OtterError ¶
type OtterError struct {
Op string // Operation that caused the error
Column string // Column name (if applicable)
Row int // Row number (if applicable, -1 if not applicable)
Message string // Human-readable error message
Cause error // Underlying error (if any)
}
OtterError represents an error that occurred during DataFrame operations
func (*OtterError) Is ¶
func (e *OtterError) Is(target error) bool
Is checks if the error matches a target error (for Go 1.13+ error handling)
func (*OtterError) Unwrap ¶
func (e *OtterError) Unwrap() error
Unwrap returns the underlying error (for Go 1.13+ error wrapping)
type Series ¶
type Series struct {
Name string // Column name
Type ColumnType // Data type
Data interface{} // Actual data: []string, []int64, []float64, []bool, []time.Time
Length int // Number of elements
}
Series represents a single column of data with a specific type