Documentation
¶
Overview ¶
Package series provides the Series type, a named typed column of data.
A Series wraps an array with a name and data type, providing a high-level API for column operations. Series are immutable after construction; all mutation operations return new Series values.
All read operations on a Series are safe for concurrent use by multiple goroutines.
Index ¶
- type DtAccessor
- func (a *DtAccessor) Day() *Series
- func (a *DtAccessor) DayOfYear() *Series
- func (a *DtAccessor) Epoch(unit string) *Series
- func (a *DtAccessor) Hour() *Series
- func (a *DtAccessor) IsoWeek() *Series
- func (a *DtAccessor) Minute() *Series
- func (a *DtAccessor) Month() *Series
- func (a *DtAccessor) Nanosecond() *Series
- func (a *DtAccessor) OffsetBy(duration string) *Series
- func (a *DtAccessor) Quarter() *Series
- func (a *DtAccessor) Second() *Series
- func (a *DtAccessor) Strftime(format string) *Series
- func (a *DtAccessor) TotalSeconds() *Series
- func (a *DtAccessor) Truncate(unit string) *Series
- func (a *DtAccessor) Weekday() *Series
- func (a *DtAccessor) Year() *Series
- type Series
- func New(name string, arr array.Array) *Series
- func NewBoolean(name string, data []bool) *Series
- func NewBooleanWithValidity(name string, data []bool, valid []bool) *Series
- func NewDate(name string, data []int32) *Series
- func NewDateTime(name string, data []int64) *Series
- func NewDateTimeWithValidity(name string, data []int64, valid []bool) *Series
- func NewDateWithValidity(name string, data []int32, valid []bool) *Series
- func NewDuration(name string, data []int64) *Series
- func NewDurationWithValidity(name string, data []int64, valid []bool) *Series
- func NewFloat32(name string, data []float32) *Series
- func NewFloat64(name string, data []float64) *Series
- func NewFloat64WithValidity(name string, data []float64, valid []bool) *Series
- func NewInt8(name string, data []int8) *Series
- func NewInt16(name string, data []int16) *Series
- func NewInt32(name string, data []int32) *Series
- func NewInt32WithValidity(name string, data []int32, valid []bool) *Series
- func NewInt64(name string, data []int64) *Series
- func NewInt64WithValidity(name string, data []int64, valid []bool) *Series
- func NewString(name string, data []string) *Series
- func NewStringWithValidity(name string, data []string, valid []bool) *Series
- func NewTime(name string, data []int64) *Series
- func NewTimeWithValidity(name string, data []int64, valid []bool) *Series
- func NewUInt8(name string, data []uint8) *Series
- func NewUInt16(name string, data []uint16) *Series
- func NewUInt32(name string, data []uint32) *Series
- func NewUInt64(name string, data []uint64) *Series
- func (s *Series) ArgMax() (int, bool)
- func (s *Series) ArgMin() (int, bool)
- func (s *Series) ArgSort(descending bool) []int
- func (s *Series) Array() array.Array
- func (s *Series) BooleanArray() *array.BooleanArray
- func (s *Series) Cast(target dtype.DataType) (*Series, error)
- func (s *Series) Count() int
- func (s *Series) CumMax() *Series
- func (s *Series) CumMin() *Series
- func (s *Series) CumProd() *Series
- func (s *Series) CumSum() *Series
- func (s *Series) DataType() dtype.DataType
- func (s *Series) Describe() string
- func (s *Series) Diff(n int) *Series
- func (s *Series) DropNulls() *Series
- func (s *Series) Dt() *DtAccessor
- func (s *Series) Equal(other *Series) bool
- func (s *Series) FillNullFloat64(fillValue float64) *Series
- func (s *Series) FillNullInt64(fillValue int64) *Series
- func (s *Series) FillNullString(fillValue string) *Series
- func (s *Series) Filter(mask *bitmap.Bitmap) *Series
- func (s *Series) Float64Values() []float64
- func (s *Series) GetBool(i int) (bool, bool)
- func (s *Series) GetFloat64(i int) (float64, bool)
- func (s *Series) GetInt32(i int) (int32, bool)
- func (s *Series) GetInt64(i int) (int64, bool)
- func (s *Series) GetString(i int) (string, bool)
- func (s *Series) HasNulls() bool
- func (s *Series) Head(n int) *Series
- func (s *Series) Int64Values() []int64
- func (s *Series) Interpolate(method string) *Series
- func (s *Series) IsDuplicated() *Series
- func (s *Series) IsNotNullSeries() *Series
- func (s *Series) IsNull(i int) bool
- func (s *Series) IsNullSeries() *Series
- func (s *Series) IsValid(i int) bool
- func (s *Series) Len() int
- func (s *Series) Max() (float64, bool)
- func (s *Series) Mean() (float64, bool)
- func (s *Series) Min() (float64, bool)
- func (s *Series) NUnique() int
- func (s *Series) Name() string
- func (s *Series) NullCount() int
- func (s *Series) PctChange(n int) *Series
- func (s *Series) Rank(method string) *Series
- func (s *Series) Rename(name string) *Series
- func (s *Series) RollingMax(window int) *Series
- func (s *Series) RollingMean(window int) *Series
- func (s *Series) RollingMin(window int) *Series
- func (s *Series) RollingStd(window int) *Series
- func (s *Series) RollingSum(window int) *Series
- func (s *Series) Shift(n int) *Series
- func (s *Series) Slice(start, end int) *Series
- func (s *Series) Sort(descending bool) *Series
- func (s *Series) Std() (float64, bool)
- func (s *Series) StdDDOF(ddof int) (float64, bool)
- func (s *Series) Str() *StrAccessor
- func (s *Series) String() string
- func (s *Series) StringArray() *array.StringArray
- func (s *Series) Sum() (float64, bool)
- func (s *Series) Tail(n int) *Series
- func (s *Series) Take(indices []int) *Series
- func (s *Series) TryCast(target dtype.DataType) *Series
- func (s *Series) Unique() *Series
- func (s *Series) Validity() *bitmap.Bitmap
- func (s *Series) Var() (float64, bool)
- func (s *Series) VarDDOF(ddof int) (float64, bool)
- type StrAccessor
- func (a *StrAccessor) Capitalize() *Series
- func (a *StrAccessor) Contains(substr string) *Series
- func (a *StrAccessor) CountMatches(pattern string) *Series
- func (a *StrAccessor) EndsWith(suffix string) *Series
- func (a *StrAccessor) Extract(pattern string, groupIndex int) *Series
- func (a *StrAccessor) Lengths() *Series
- func (a *StrAccessor) Pad(width int, side string, fillChar rune) *Series
- func (a *StrAccessor) Replace(old, new string) *Series
- func (a *StrAccessor) Slice(start, length int) *Series
- func (a *StrAccessor) Split(sep string, index int) *Series
- func (a *StrAccessor) StartsWith(prefix string) *Series
- func (a *StrAccessor) Strip(chars string) *Series
- func (a *StrAccessor) ToDatetime(layout string) *Series
- func (a *StrAccessor) ToLower() *Series
- func (a *StrAccessor) ToUpper() *Series
- func (a *StrAccessor) Trim() *Series
- func (a *StrAccessor) ZFill(width int) *Series
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DtAccessor ¶
type DtAccessor struct {
// contains filtered or unexported fields
}
DtAccessor provides temporal operations on Date/DateTime/Time/Duration Series.
func (*DtAccessor) Day ¶
func (a *DtAccessor) Day() *Series
Day returns an Int32 Series with the day of month component.
func (*DtAccessor) DayOfYear ¶
func (a *DtAccessor) DayOfYear() *Series
DayOfYear returns an Int32 Series with the day of year (1-366).
func (*DtAccessor) Epoch ¶
func (a *DtAccessor) Epoch(unit string) *Series
Epoch returns an Int64 Series with the epoch value in the given time unit. Supported units: "s" (seconds), "ms" (milliseconds), "us" (microseconds), "ns" (nanoseconds).
func (*DtAccessor) Hour ¶
func (a *DtAccessor) Hour() *Series
Hour returns an Int32 Series with the hour component.
func (*DtAccessor) IsoWeek ¶
func (a *DtAccessor) IsoWeek() *Series
IsoWeek returns an Int32 Series with the ISO week number.
func (*DtAccessor) Minute ¶
func (a *DtAccessor) Minute() *Series
Minute returns an Int32 Series with the minute component.
func (*DtAccessor) Month ¶
func (a *DtAccessor) Month() *Series
Month returns an Int32 Series with the month component (1-12).
func (*DtAccessor) Nanosecond ¶
func (a *DtAccessor) Nanosecond() *Series
Nanosecond returns an Int32 Series with the nanosecond component.
func (*DtAccessor) OffsetBy ¶
func (a *DtAccessor) OffsetBy(duration string) *Series
OffsetBy offsets temporal values by a duration string. Supported formats: "1d", "2mo", "-1y", "3h", etc.
func (*DtAccessor) Quarter ¶
func (a *DtAccessor) Quarter() *Series
Quarter returns an Int32 Series with the quarter (1-4).
func (*DtAccessor) Second ¶
func (a *DtAccessor) Second() *Series
Second returns an Int32 Series with the second component.
func (*DtAccessor) Strftime ¶
func (a *DtAccessor) Strftime(format string) *Series
Strftime formats temporal values using a Go time format string.
func (*DtAccessor) TotalSeconds ¶
func (a *DtAccessor) TotalSeconds() *Series
TotalSeconds returns a Float64 Series with the total duration in seconds. Only applicable to Duration series (microseconds).
func (*DtAccessor) Truncate ¶
func (a *DtAccessor) Truncate(unit string) *Series
Truncate truncates temporal values to the given unit. Supported units: "1h", "1d", "1mo", "1y"
func (*DtAccessor) Weekday ¶
func (a *DtAccessor) Weekday() *Series
Weekday returns an Int32 Series with the weekday (0=Sunday, 6=Saturday).
func (*DtAccessor) Year ¶
func (a *DtAccessor) Year() *Series
Year returns an Int32 Series with the year component.
type Series ¶
type Series struct {
// contains filtered or unexported fields
}
Series is a named, typed column of data. It wraps an underlying columnar array with a name and provides a rich API for data manipulation.
func NewBoolean ¶
NewBoolean creates a new Series of boolean values.
func NewBooleanWithValidity ¶
NewBooleanWithValidity creates a Boolean Series with explicit null tracking.
func NewDateTime ¶
NewDateTime creates a new Series of DateTime values (microseconds since epoch as int64).
func NewDateTimeWithValidity ¶
NewDateTimeWithValidity creates a DateTime Series with explicit null tracking.
func NewDateWithValidity ¶
NewDateWithValidity creates a Date Series with explicit null tracking.
func NewDuration ¶
NewDuration creates a new Series of Duration values (microseconds as int64).
func NewDurationWithValidity ¶
NewDurationWithValidity creates a Duration Series with explicit null tracking.
func NewFloat32 ¶
NewFloat32 creates a new Series of float32 values.
func NewFloat64 ¶
NewFloat64 creates a new Series of float64 values.
func NewFloat64WithValidity ¶
NewFloat64WithValidity creates a Float64 Series with explicit null tracking.
func NewInt32WithValidity ¶
NewInt32WithValidity creates an Int32 Series with explicit null tracking.
func NewInt64WithValidity ¶
NewInt64WithValidity creates an Int64 Series with explicit null tracking. Positions where valid[i] is false are marked as null.
func NewStringWithValidity ¶
NewStringWithValidity creates a String Series with explicit null tracking.
func NewTimeWithValidity ¶
NewTimeWithValidity creates a Time Series with explicit null tracking.
func (*Series) ArgMax ¶
ArgMax returns the index of the maximum non-null value. Returns -1, false if the series is empty or all null.
func (*Series) ArgMin ¶
ArgMin returns the index of the minimum non-null value. Returns -1, false if the series is empty or all null.
func (*Series) ArgSort ¶
ArgSort returns the indices that would sort this Series. Nulls are placed at the end.
func (*Series) BooleanArray ¶
func (s *Series) BooleanArray() *array.BooleanArray
BooleanArray returns the underlying BooleanArray, or nil if wrong type.
func (*Series) Cast ¶
Cast converts the Series to the target data type. Supported casts:
- Int64 <-> Float64 (numeric conversion)
- Int64/Float64 -> String (formatting)
- String -> Int64/Float64 (parsing, invalid values become null)
- Boolean -> Int64 (true=1, false=0)
- Int64 -> Boolean (0=false, nonzero=true)
func (*Series) CumMax ¶
CumMax returns a new Series with the cumulative maximum. Only supports Int64 and Float64 types. Other types return nil.
func (*Series) CumMin ¶
CumMin returns a new Series with the cumulative minimum. Only supports Int64 and Float64 types. Other types return nil.
func (*Series) CumProd ¶
CumProd returns a new Series with the cumulative product. Only supports Int64 and Float64 types. Other types return nil.
func (*Series) CumSum ¶
CumSum returns a new Series with the cumulative sum. Only supports Int64 and Float64 types. Other types return nil.
func (*Series) Diff ¶
Diff returns a new Series with the difference between each element and the element n positions before it. The first n values will be null. Only supports Int64 and Float64 types.
func (*Series) Dt ¶
func (s *Series) Dt() *DtAccessor
Dt returns a DtAccessor for temporal operations. Returns nil if the Series is not of a temporal type (Date, DateTime, Time, Duration).
func (*Series) FillNullFloat64 ¶
FillNullFloat64 returns a new Float64 Series with nulls replaced by the given value.
func (*Series) FillNullInt64 ¶
FillNullInt64 returns a new Int64 Series with nulls replaced by the given value.
func (*Series) FillNullString ¶
FillNullString returns a new String Series with nulls replaced by the given value.
func (*Series) Filter ¶
Filter returns a new Series containing only elements where mask bits are set.
func (*Series) Float64Values ¶
Float64Values returns the underlying float64 slice, or nil if wrong type.
func (*Series) GetFloat64 ¶
GetFloat64 returns the float64 value at index i and whether it's valid.
func (*Series) Int64Values ¶
Int64Values returns the underlying int64 slice, or nil if wrong type.
func (*Series) Interpolate ¶
Interpolate fills null values using the specified method. Supported methods: "linear", "pad"/"ffill" (forward fill), "bfill" (backward fill). Only works for numeric types. The "linear" method always returns Float64.
func (*Series) IsDuplicated ¶
IsDuplicated returns a Boolean Series where true indicates the value at that position appears more than once in the Series.
func (*Series) IsNotNullSeries ¶
IsNotNullSeries returns a Boolean Series where true indicates a non-null in the original.
func (*Series) IsNullSeries ¶
IsNullSeries returns a Boolean Series where true indicates a null in the original.
func (*Series) Max ¶
Max returns the maximum non-null value as a float64. The second return value is false if the series is empty or all null.
func (*Series) Mean ¶
Mean returns the arithmetic mean of all non-null values. The second return value is false if the series is empty or all null.
func (*Series) Min ¶
Min returns the minimum non-null value as a float64. The second return value is false if the series is empty or all null.
func (*Series) NUnique ¶
NUnique returns the number of unique non-null values. This is an O(n) operation that uses a hash set internally.
func (*Series) PctChange ¶
PctChange returns the percentage change between each element and the element n positions before it. Results are Float64. The first n values will be null.
func (*Series) Rank ¶
Rank assigns ranks to the values in the series. Supported methods: "average", "min", "max", "dense", "ordinal". Null values receive null in the output.
func (*Series) RollingMax ¶
RollingMax computes the rolling maximum with the given window size. Returns a Float64 Series. The first (window-1) values are null.
func (*Series) RollingMean ¶
RollingMean computes the rolling mean with the given window size. Returns a Float64 Series. The first (window-1) values are null.
func (*Series) RollingMin ¶
RollingMin computes the rolling minimum with the given window size. Returns a Float64 Series. The first (window-1) values are null.
func (*Series) RollingStd ¶
RollingStd computes the rolling standard deviation with the given window size. Returns a Float64 Series. The first (window-1) values are null.
func (*Series) RollingSum ¶
RollingSum computes the rolling sum with the given window size. Returns a Float64 Series. The first (window-1) values are null.
func (*Series) Shift ¶
Shift returns a new Series with values shifted by n positions. Positive n shifts down (introduces nulls at the top). Negative n shifts up (introduces nulls at the bottom).
func (*Series) Std ¶
Std returns the standard deviation of all non-null values. Uses ddof=1 (sample standard deviation) by default.
func (*Series) StdDDOF ¶
StdDDOF returns the standard deviation with the specified delta degrees of freedom.
func (*Series) Str ¶
func (s *Series) Str() *StrAccessor
Str returns a StrAccessor for string operations. Returns nil if the Series is not of String type.
func (*Series) StringArray ¶
func (s *Series) StringArray() *array.StringArray
StringArray returns the underlying StringArray, or nil if wrong type.
func (*Series) Sum ¶
Sum returns the sum of all non-null values as a float64. The second return value is false if the series is empty or all null.
func (*Series) TryCast ¶
TryCast attempts to cast the series to the target type, returning null on failure instead of an error. This is a permissive version of Cast.
func (*Series) Unique ¶
Unique returns a new Series containing only unique values. Order is preserved (first occurrence is kept). Null appears at most once in the result.
type StrAccessor ¶
type StrAccessor struct {
// contains filtered or unexported fields
}
StrAccessor provides string operations on a String Series.
func (*StrAccessor) Capitalize ¶
func (a *StrAccessor) Capitalize() *Series
Capitalize returns a new String Series with the first character of each string uppercased and the rest lowercased.
func (*StrAccessor) Contains ¶
func (a *StrAccessor) Contains(substr string) *Series
Contains returns a Boolean Series indicating whether each string contains substr.
func (*StrAccessor) CountMatches ¶
func (a *StrAccessor) CountMatches(pattern string) *Series
CountMatches counts the number of non-overlapping matches of a regex pattern.
func (*StrAccessor) EndsWith ¶
func (a *StrAccessor) EndsWith(suffix string) *Series
EndsWith returns a Boolean Series indicating whether each string ends with suffix.
func (*StrAccessor) Extract ¶
func (a *StrAccessor) Extract(pattern string, groupIndex int) *Series
Extract extracts the first match of a regex pattern, returning the given group. groupIndex 0 returns the full match; 1+ return capture groups.
func (*StrAccessor) Lengths ¶
func (a *StrAccessor) Lengths() *Series
Lengths returns an Int64 Series with the length (in runes) of each string.
func (*StrAccessor) Pad ¶
func (a *StrAccessor) Pad(width int, side string, fillChar rune) *Series
Pad pads each string to the given width with fillChar. side must be "left", "right", or "both".
func (*StrAccessor) Replace ¶
func (a *StrAccessor) Replace(old, new string) *Series
Replace replaces all occurrences of old with new in each string.
func (*StrAccessor) Slice ¶
func (a *StrAccessor) Slice(start, length int) *Series
Slice extracts a substring from each string using start and length.
func (*StrAccessor) Split ¶
func (a *StrAccessor) Split(sep string, index int) *Series
Split splits each string by the separator and returns a new String Series containing the nth element (0-indexed). If the index is out of range, the value is null.
func (*StrAccessor) StartsWith ¶
func (a *StrAccessor) StartsWith(prefix string) *Series
StartsWith returns a Boolean Series indicating whether each string starts with prefix.
func (*StrAccessor) Strip ¶
func (a *StrAccessor) Strip(chars string) *Series
Strip removes the given characters from both ends of each string.
func (*StrAccessor) ToDatetime ¶
func (a *StrAccessor) ToDatetime(layout string) *Series
ToDatetime parses each string into a DateTime Series using the given Go time layout. Returns a DateTime Series (microseconds since epoch). Unparseable values become null.
func (*StrAccessor) ToLower ¶
func (a *StrAccessor) ToLower() *Series
ToLower returns a new String Series with all characters lowercased.
func (*StrAccessor) ToUpper ¶
func (a *StrAccessor) ToUpper() *Series
ToUpper returns a new String Series with all characters uppercased.
func (*StrAccessor) Trim ¶
func (a *StrAccessor) Trim() *Series
Trim removes leading and trailing whitespace from each string.
func (*StrAccessor) ZFill ¶
func (a *StrAccessor) ZFill(width int) *Series
ZFill pads each string on the left with '0' to the given width.