Documentation
¶
Overview ¶
Package series defines Series, a named, chunked, nullable column.
A Series is the building block of a DataFrame. It wraps a chunked arrow array with a column name and exposes dtype-aware accessors.
Reference counting. A Series owns one reference to its underlying arrow.Chunked. Constructors consume the arrow.Array references passed in: after a successful call, the caller must not release the input arrays. Methods that return a new Series (Rename, Slice, Clone) share the underlying buffers through refcounting and do not copy data. Call Release when you are done with a Series to drop its reference.
Index ¶
- Variables
- func AndValidityBitmap(a, b arrow.Array, alloc memory.Allocator) (*memory.Buffer, int)
- func CopyValidityBitmap(a arrow.Array, alloc memory.Allocator) *memory.Buffer
- type ListOps
- func (o ListOps) Contains(v any) (*Series, error)
- func (o ListOps) First() (*Series, error)
- func (o ListOps) Get(idx int) (*Series, error)
- func (o ListOps) Join(sep string) (*Series, error)
- func (o ListOps) Last() (*Series, error)
- func (o ListOps) Len() (*Series, error)
- func (o ListOps) Max() (*Series, error)
- func (o ListOps) Mean() (*Series, error)
- func (o ListOps) Min() (*Series, error)
- func (o ListOps) Sum() (*Series, error)
- type Option
- type RankMethod
- type RollingOptions
- type Series
- func BuildBoolDirect(name string, n int, mem memory.Allocator, fill func(bits []byte)) (*Series, error)
- func BuildBoolDirectWithValidity(name string, n int, mem memory.Allocator, fill func(bits []byte), ...) (*Series, error)
- func BuildFloat64Direct(name string, n int, mem memory.Allocator, fill func(out []float64)) (*Series, error)
- func BuildFloat64DirectFused(name string, n int, mem memory.Allocator, ...) (*Series, error)
- func BuildFloat64DirectNullable(name string, n int, mem memory.Allocator, fill func(out []float64), ...) (*Series, error)
- func BuildFloat64DirectWithValidity(name string, n int, mem memory.Allocator, fill func(out []float64), ...) (*Series, error)
- func BuildInt64Direct(name string, n int, mem memory.Allocator, fill func(out []int64)) (*Series, error)
- func BuildInt64DirectFused(name string, n int, mem memory.Allocator, ...) (*Series, error)
- func BuildInt64DirectNullable(name string, n int, mem memory.Allocator, fill func(out []int64), valid []bool) (*Series, error)
- func BuildInt64DirectWithValidity(name string, n int, mem memory.Allocator, fill func(out []int64), ...) (*Series, error)
- func BuildTypedInt32Direct(name string, n int, mem memory.Allocator, dt arrow.DataType, valid []bool, ...) (*Series, error)
- func BuildTypedInt64Direct(name string, n int, mem memory.Allocator, dt arrow.DataType, valid []bool, ...) (*Series, error)
- func Empty(name string, dt dtype.DType) *Series
- func FromArrowArray(name string, a arrow.Array) (*Series, error)
- func FromArrowChunked(name string, c *arrow.Chunked) *Series
- func FromBool(name string, values []bool, valid []bool, opts ...Option) (*Series, error)
- func FromChunked(name string, chunked *arrow.Chunked) *Series
- func FromFloat32(name string, values []float32, valid []bool, opts ...Option) (*Series, error)
- func FromFloat64(name string, values []float64, valid []bool, opts ...Option) (*Series, error)
- func FromInt32(name string, values []int32, valid []bool, opts ...Option) (*Series, error)
- func FromInt64(name string, values []int64, valid []bool, opts ...Option) (*Series, error)
- func FromString(name string, values []string, valid []bool, opts ...Option) (*Series, error)
- func FromTime(name string, values []int64, valid []bool, dt dtype.DType, opts ...Option) (*Series, error)
- func FromUint32(name string, values []uint32, valid []bool, opts ...Option) (*Series, error)
- func FromUint64(name string, values []uint64, valid []bool, opts ...Option) (*Series, error)
- func New(name string, chunks ...arrow.Array) (*Series, error)
- func (s *Series) Abs(opts ...Option) (*Series, error)
- func (s *Series) All() (bool, error)
- func (s *Series) Any() (bool, error)
- func (s *Series) ApplyBool(fn func(bool) bool, opts ...Option) (*Series, error)
- func (s *Series) ApplyFloat64(fn func(float64) float64, opts ...Option) (*Series, error)
- func (s *Series) ApplyInt64(fn func(int64) int64, opts ...Option) (*Series, error)
- func (s *Series) ApplyString(fn func(string) string, opts ...Option) (*Series, error)
- func (s *Series) ApproxNUnique() (int, error)
- func (s *Series) Arccos(opts ...Option) (*Series, error)
- func (s *Series) Arccosh(opts ...Option) (*Series, error)
- func (s *Series) Arcsin(opts ...Option) (*Series, error)
- func (s *Series) Arcsinh(opts ...Option) (*Series, error)
- func (s *Series) Arctan(opts ...Option) (*Series, error)
- func (s *Series) Arctan2(other *Series, opts ...Option) (*Series, error)
- func (s *Series) Arctanh(opts ...Option) (*Series, error)
- func (s *Series) ArgMax() (int, error)
- func (s *Series) ArgMin() (int, error)
- func (s *Series) ArgSort() ([]int, error)
- func (s *Series) ArgTrue() ([]int64, error)
- func (s *Series) ArgUnique() ([]int64, error)
- func (s *Series) BackwardFill(limit int, opts ...Option) (*Series, error)
- func (s *Series) BottomK(k int, opts ...Option) (*Series, error)
- func (s *Series) Cbrt(opts ...Option) (*Series, error)
- func (s *Series) Ceil(opts ...Option) (*Series, error)
- func (s *Series) Chunk(i int) arrow.Array
- func (s *Series) Chunked() *arrow.Chunked
- func (s *Series) Chunks() []arrow.Array
- func (s *Series) Clip(lo, hi float64, opts ...Option) (*Series, error)
- func (s *Series) Clone() *Series
- func (s *Series) Consolidated() (arrow.Array, error)
- func (s *Series) Cos(opts ...Option) (*Series, error)
- func (s *Series) Cosh(opts ...Option) (*Series, error)
- func (s *Series) Cot(opts ...Option) (*Series, error)
- func (s *Series) Covariance(other *Series, ddof int) (float64, error)
- func (s *Series) CumCount(opts ...Option) (*Series, error)
- func (s *Series) CumMax(opts ...Option) (*Series, error)
- func (s *Series) CumMin(opts ...Option) (*Series, error)
- func (s *Series) CumProd(opts ...Option) (*Series, error)
- func (s *Series) CumSum(opts ...Option) (*Series, error)
- func (s *Series) DType() dtype.DType
- func (s *Series) Degrees(opts ...Option) (*Series, error)
- func (s *Series) Diff(periods int, opts ...Option) (*Series, error)
- func (s *Series) DropNulls(opts ...Option) (*Series, error)
- func (s *Series) EWMMean(alpha float64) (*Series, error)
- func (s *Series) EWMStd(alpha float64) (*Series, error)
- func (s *Series) EWMVar(alpha float64) (*Series, error)
- func (s *Series) Entropy(base float64) (float64, error)
- func (s *Series) Equal(other *Series) bool
- func (s *Series) Exp(opts ...Option) (*Series, error)
- func (s *Series) Expm1(opts ...Option) (*Series, error)
- func (s *Series) ExtendConstant(v any, n int, opts ...Option) (*Series, error)
- func (s *Series) FillNan(value float64, opts ...Option) (*Series, error)
- func (s *Series) FillNull(value any, opts ...Option) (*Series, error)
- func (s *Series) FirstNonNull() (value any, index int, err error)
- func (s *Series) Floor(opts ...Option) (*Series, error)
- func (s *Series) Format(opts SeriesFormatOptions) string
- func (s *Series) ForwardFill(limit int, opts ...Option) (*Series, error)
- func (s *Series) HasNulls() bool
- func (s *Series) Hash(opts ...Option) (*Series, error)
- func (s *Series) Head(n int, opts ...Option) (*Series, error)
- func (s *Series) IndexOf(v any) (int, error)
- func (s *Series) IsDuplicated(opts ...Option) (*Series, error)
- func (s *Series) IsEmpty() bool
- func (s *Series) IsFinite(opts ...Option) (*Series, error)
- func (s *Series) IsFirstDistinct(opts ...Option) (*Series, error)
- func (s *Series) IsInfinite(opts ...Option) (*Series, error)
- func (s *Series) IsLastDistinct(opts ...Option) (*Series, error)
- func (s *Series) IsNaN(opts ...Option) (*Series, error)
- func (s *Series) IsNotNull(opts ...Option) (*Series, error)
- func (s *Series) IsNull(opts ...Option) (*Series, error)
- func (s *Series) IsSorted(order SortedOrder) (bool, error)
- func (s *Series) IsUnique(opts ...Option) (*Series, error)
- func (s *Series) Kurtosis() (float64, error)
- func (s *Series) KurtosisUnbiased() (float64, error)
- func (s *Series) Len() int
- func (s *Series) List() ListOps
- func (s *Series) Log(opts ...Option) (*Series, error)
- func (s *Series) Log1p(opts ...Option) (*Series, error)
- func (s *Series) Log2(opts ...Option) (*Series, error)
- func (s *Series) Log10(opts ...Option) (*Series, error)
- func (s *Series) Max() (float64, error)
- func (s *Series) Mean() (float64, error)
- func (s *Series) Median() (float64, error)
- func (s *Series) Min() (float64, error)
- func (s *Series) Mode(opts ...Option) (*Series, error)
- func (s *Series) NUnique() (int, error)
- func (s *Series) Name() string
- func (s *Series) NullCount() int
- func (s *Series) NumChunks() int
- func (s *Series) PctChange(periods int, opts ...Option) (*Series, error)
- func (s *Series) PeakMax(opts ...Option) (*Series, error)
- func (s *Series) PeakMin(opts ...Option) (*Series, error)
- func (s *Series) PearsonCorr(other *Series) (float64, error)
- func (s *Series) Pow(exponent float64, opts ...Option) (*Series, error)
- func (s *Series) Product() (float64, error)
- func (s *Series) Quantile(q float64) (float64, error)
- func (s *Series) Radians(opts ...Option) (*Series, error)
- func (s *Series) Rank(method RankMethod, opts ...Option) (*Series, error)
- func (s *Series) Rechunk() *Series
- func (s *Series) Release()
- func (s *Series) Rename(name string) *Series
- func (s *Series) Retain()
- func (s *Series) Reverse(opts ...Option) (*Series, error)
- func (s *Series) RollingMax(opts RollingOptions, callerOpts ...Option) (*Series, error)
- func (s *Series) RollingMean(opts RollingOptions, callerOpts ...Option) (*Series, error)
- func (s *Series) RollingMin(opts RollingOptions, callerOpts ...Option) (*Series, error)
- func (s *Series) RollingStd(opts RollingOptions, callerOpts ...Option) (*Series, error)
- func (s *Series) RollingSum(opts RollingOptions, callerOpts ...Option) (*Series, error)
- func (s *Series) RollingVar(opts RollingOptions, callerOpts ...Option) (*Series, error)
- func (s *Series) Round(decimals int, opts ...Option) (*Series, error)
- func (s *Series) Sample(n int, withReplacement bool, seed uint64, opts ...Option) (*Series, error)
- func (s *Series) SampleFrac(fraction float64, withReplacement bool, seed uint64, opts ...Option) (*Series, error)
- func (s *Series) SearchSorted(v any) (int, error)
- func (s *Series) Shift(periods int, opts ...Option) (*Series, error)
- func (s *Series) Shuffle(seed uint64, opts ...Option) (*Series, error)
- func (s *Series) Sign(opts ...Option) (*Series, error)
- func (s *Series) Sin(opts ...Option) (*Series, error)
- func (s *Series) Sinh(opts ...Option) (*Series, error)
- func (s *Series) Skew() (float64, error)
- func (s *Series) SkewUnbiased() (float64, error)
- func (s *Series) Slice(offset, length int) (*Series, error)
- func (s *Series) Sqrt(opts ...Option) (*Series, error)
- func (s *Series) Std() (float64, error)
- func (s *Series) Str() StrOps
- func (s *Series) String() string
- func (s *Series) Struct() StructOps
- func (s *Series) Sum() (float64, error)
- func (s *Series) Summary() string
- func (s *Series) Tail(n int, opts ...Option) (*Series, error)
- func (s *Series) Tan(opts ...Option) (*Series, error)
- func (s *Series) Tanh(opts ...Option) (*Series, error)
- func (s *Series) ToArrow() arrow.Array
- func (s *Series) ToArrowChunked() *arrow.Chunked
- func (s *Series) TopK(k int, opts ...Option) (*Series, error)
- func (s *Series) Unique(opts ...Option) (*Series, error)
- func (s *Series) ValueCounts(sortByCount bool, opts ...Option) (values, counts *Series, err error)
- func (s *Series) Var() (float64, error)
- type SeriesFormatOptions
- type SortedOrder
- type StrOps
- func (o StrOps) After(sep string, opts ...Option) (*Series, error)
- func (o StrOps) Before(sep string, opts ...Option) (*Series, error)
- func (o StrOps) Concat(suffix string, opts ...Option) (*Series, error)
- func (o StrOps) Contains(needle string, opts ...Option) (*Series, error)
- func (o StrOps) ContainsRegex(pattern string, opts ...Option) (*Series, error)
- func (o StrOps) CountMatches(needle string, opts ...Option) (*Series, error)
- func (o StrOps) CountMatchesRegex(pattern string, opts ...Option) (*Series, error)
- func (o StrOps) EndsWith(suffix string, opts ...Option) (*Series, error)
- func (o StrOps) Extract(pattern string, group int, opts ...Option) (*Series, error)
- func (o StrOps) Find(needle string, opts ...Option) (*Series, error)
- func (o StrOps) Head(n int, opts ...Option) (*Series, error)
- func (o StrOps) IsNumeric(opts ...Option) (*Series, error)
- func (o StrOps) LStrip(cutset string, opts ...Option) (*Series, error)
- func (o StrOps) LenBytes(opts ...Option) (*Series, error)
- func (o StrOps) LenChars(opts ...Option) (*Series, error)
- func (o StrOps) Like(pattern string, opts ...Option) (*Series, error)
- func (o StrOps) Lower(opts ...Option) (*Series, error)
- func (o StrOps) NotLike(pattern string, opts ...Option) (*Series, error)
- func (o StrOps) PadEnd(totalLen int, pad rune, opts ...Option) (*Series, error)
- func (o StrOps) PadStart(totalLen int, pad rune, opts ...Option) (*Series, error)
- func (o StrOps) Prefix(prefix string, opts ...Option) (*Series, error)
- func (o StrOps) RStrip(cutset string, opts ...Option) (*Series, error)
- func (o StrOps) Replace(old, new string, opts ...Option) (*Series, error)
- func (o StrOps) ReplaceAll(old, new string, opts ...Option) (*Series, error)
- func (o StrOps) ReplaceRegex(pattern, repl string, opts ...Option) (*Series, error)
- func (o StrOps) Reverse(opts ...Option) (*Series, error)
- func (o StrOps) Slice(start, length int, opts ...Option) (*Series, error)
- func (o StrOps) SplitExact(sep string, opts ...Option) (*Series, error)
- func (o StrOps) SplitExactNullShort(sep string, idx int, opts ...Option) (*Series, error)
- func (o StrOps) SplitN(sep string, idx int, opts ...Option) (*Series, error)
- func (o StrOps) SplitNth(sep string, n int, opts ...Option) (*Series, error)
- func (o StrOps) SplitWide(sep string, maxN int, opts ...Option) ([]*Series, error)
- func (o StrOps) StartsWith(prefix string, opts ...Option) (*Series, error)
- func (o StrOps) StripPrefix(prefix string, opts ...Option) (*Series, error)
- func (o StrOps) StripSuffix(suffix string, opts ...Option) (*Series, error)
- func (o StrOps) Tail(n int, opts ...Option) (*Series, error)
- func (o StrOps) Title(opts ...Option) (*Series, error)
- func (o StrOps) ToLowercase(opts ...Option) (*Series, error)
- func (o StrOps) ToUppercase(opts ...Option) (*Series, error)
- func (o StrOps) Trim(opts ...Option) (*Series, error)
- func (o StrOps) Upper(opts ...Option) (*Series, error)
- func (o StrOps) ZFill(totalLen int, opts ...Option) (*Series, error)
- type StructOps
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyChunks = errors.New("series: at least one chunk required") ErrChunkDTypeMismatch = errors.New("series: chunks have mismatched dtypes") ErrSliceOutOfBounds = errors.New("series: slice out of bounds") ErrLengthMismatch = errors.New("series: values and valid mask have different lengths") )
Sentinel errors returned by Series operations.
var FillNullFloat64Accel func(condBits []byte, src []float64, lit float64, out []float64) int
FillNullFloat64Accel is the float64 counterpart. float64 fills blend identically to int64 at the bit level, so the same kernel handles both once the values are reinterpreted.
FillNullInt64Accel is the SIMD acceleration hook for the int64 FillNull kernel. compute.init registers an AVX2/NEON implementation when the build tags and runtime feature detection agree. Set to nil means "no acceleration available" - the pure-Go single-pass blend below is used.
The registered function should write src[i] to out[i] for every position where condBits bit i is set, and lit elsewhere, returning the number of elements handled (always a multiple of 8 for AVX2, multiple of 2 for NEON). Caller handles the scalar tail.
Functions ¶
func AndValidityBitmap ¶
AndValidityBitmap returns (buf, nullCount) where buf holds bit i set iff a.IsValid(i) AND b.IsValid(i). Returns (nil, 0) when neither input has nulls.
func CopyValidityBitmap ¶
CopyValidityBitmap returns a fresh memory.Buffer holding a's validity bitmap, or nil when a has no nulls. Caller owns the returned buffer.
Offset-aware: if a is a slice view (offset > 0), the returned bitmap is rebased so bit 0 corresponds to element 0 of the slice.
Types ¶
type ListOps ¶
type ListOps struct {
// contains filtered or unexported fields
}
ListOps is the namespace for operations over list-typed Series. Reach it via `s.List()`. Mirrors polars' `s.list.*` surface.
func (ListOps) Contains ¶
Contains returns a boolean Series marking rows whose inner list holds the given scalar. The scalar's Go type must match the list's inner dtype.
func (ListOps) First ¶
First returns the first element of each inner list (equivalent to Get(0)). Null/empty lists yield null.
func (ListOps) Get ¶
Get returns the element at position idx from each inner list. Negative idx counts from the back. Out-of-range positions yield null. Supported inner dtypes: Int64, Int32, Float64, Float32, String, Boolean.
func (ListOps) Join ¶
Join concatenates the string elements of each inner list with the given separator. Requires the inner dtype to be utf8. Null inner elements are skipped; null or empty lists produce "" (matching polars' default).
func (ListOps) Last ¶
Last returns the last element of each inner list. Null/empty lists yield null.
func (ListOps) Len ¶
Len returns the length of each inner list as an int64 Series. Nulls in the input are null in the output.
func (ListOps) Max ¶
Max returns the maximum of each inner list. Dtype matches the list's inner scalar type.
func (ListOps) Mean ¶
Mean returns the arithmetic mean of each inner list as float64. Empty and null lists yield null.
type Option ¶
type Option func(*config)
Option configures an allocating constructor.
func WithAllocator ¶
WithAllocator overrides the memory allocator used by a constructor.
type RankMethod ¶
type RankMethod int
RankMethod controls how ties are broken in Rank. Polars-compatible values: Average (default), Min, Max, Dense, Ordinal.
const ( // RankAverage assigns the mean of the tied ranks. RankAverage RankMethod = iota // RankMin assigns the lowest of the tied ranks. RankMin // RankMax assigns the highest of the tied ranks. RankMax // RankDense assigns consecutive ranks with no gaps. RankDense // RankOrdinal breaks ties by position (first tied value gets the // lowest rank). RankOrdinal )
type RollingOptions ¶
type RollingOptions struct {
// WindowSize is the number of rows per window. Must be >= 1.
WindowSize int
// MinPeriods is the minimum non-null count required to produce a
// value; windows with fewer valid entries emit null. Defaults to
// WindowSize when 0.
MinPeriods int
}
RollingOptions configures a rolling aggregation. Mirrors polars' RollingOptions for fixed-size windows.
type Series ¶
type Series struct {
// contains filtered or unexported fields
}
Series is a named column backed by a chunked arrow array.
func BuildBoolDirect ¶
func BuildBoolDirect(name string, n int, mem memory.Allocator, fill func(bits []byte)) (*Series, error)
BuildBoolDirect constructs a Boolean Series with a pre-packed bitmap. bits is the caller-supplied bit buffer, little-endian bit order, length bitutil.CeilByte(n)/8 bytes. This avoids the per-bit BuilderAppend loop.
func BuildBoolDirectWithValidity ¶
func BuildBoolDirectWithValidity(name string, n int, mem memory.Allocator, fill func(bits []byte), nullBuf *memory.Buffer, nullCount int, ) (*Series, error)
BuildBoolDirectWithValidity is BuildBoolDirect plus a caller- supplied validity bitmap. Data bits go in the `fill` callback's bitmap; validity stays in nullBuf. Use this to avoid the []bool round-trip in compare kernels that have both.
func BuildFloat64Direct ¶
func BuildFloat64Direct(name string, n int, mem memory.Allocator, fill func(out []float64)) (*Series, error)
BuildFloat64Direct is the float64 variant of BuildInt64Direct.
func BuildFloat64DirectFused ¶
func BuildFloat64DirectFused(name string, n int, mem memory.Allocator, fill func(out []float64, validBits []byte) int) (*Series, error)
BuildFloat64DirectFused is the float64 counterpart of BuildInt64DirectFused.
func BuildFloat64DirectNullable ¶
func BuildFloat64DirectNullable(name string, n int, mem memory.Allocator, fill func(out []float64), valid []bool) (*Series, error)
BuildFloat64DirectNullable is the nullable-output variant for float64.
func BuildFloat64DirectWithValidity ¶
func BuildFloat64DirectWithValidity(name string, n int, mem memory.Allocator, fill func(out []float64), nullBuf *memory.Buffer, nullCount int, ) (*Series, error)
BuildFloat64DirectWithValidity is the float64 counterpart.
func BuildInt64Direct ¶
func BuildInt64Direct(name string, n int, mem memory.Allocator, fill func(out []int64)) (*Series, error)
BuildInt64Direct constructs an Int64 Series by allocating an allocator-tracked buffer once and handing it to the caller as []int64 to fill. This is the direct-write path mimicked from polars' MutablePrimitiveArray and arrow-go's array.NewData constructor: it avoids the memcpy that FromInt64 / AppendValues incur, cutting the output-cost floor of binary kernels and Filter roughly in half.
fill receives a []int64 of length n aliasing the underlying buffer. Every slot must be written; unwritten slots contain arbitrary memory. The returned Series owns its reference and can be Released normally.
func BuildInt64DirectFused ¶
func BuildInt64DirectFused(name string, n int, mem memory.Allocator, fill func(out []int64, validBits []byte) int) (*Series, error)
BuildInt64DirectFused is the fused-fill nullable variant: the callback receives both the output value slice AND the packed bitmap buffer, and returns the null count. This lets the caller write to values and the validity bitmap in a single pass, saving an n-sized []bool allocation plus a second pass to pack it. Mirrors BuildFloat64DirectFused.
func BuildInt64DirectNullable ¶
func BuildInt64DirectNullable(name string, n int, mem memory.Allocator, fill func(out []int64), valid []bool) (*Series, error)
BuildInt64DirectNullable is the nullable-output variant. valid is a []bool of length n where true marks a valid value. A nil valid slice means every value is valid (in which case BuildInt64Direct is preferred).
func BuildInt64DirectWithValidity ¶
func BuildInt64DirectWithValidity(name string, n int, mem memory.Allocator, fill func(out []int64), nullBuf *memory.Buffer, nullCount int, ) (*Series, error)
BuildInt64DirectWithValidity is BuildInt64Direct plus a caller- supplied validity bitmap. The buffer is consumed: the returned Series takes ownership and the caller must not Release nullBuf afterward.
Passing nil nullBuf is legal and means "no nulls".
func BuildTypedInt32Direct ¶
func BuildTypedInt32Direct(name string, n int, mem memory.Allocator, dt arrow.DataType, valid []bool, fill func(out []int32)) (*Series, error)
BuildTypedInt32Direct is the int32-backed sibling for DATE32 / TIME32.
func BuildTypedInt64Direct ¶
func BuildTypedInt64Direct(name string, n int, mem memory.Allocator, dt arrow.DataType, valid []bool, fill func(out []int64)) (*Series, error)
BuildTypedInt64Direct is BuildInt64Direct that preserves a caller-supplied DataType. Used to gather values into int64-backed temporal dtypes (TIMESTAMP, DATE64, TIME64, DURATION) without collapsing them to plain Int64. valid is optional; nil means all values are valid.
func FromArrowArray ¶
FromArrowArray wraps an arrow.Array as a single-chunk Series. Consumes the caller's reference on success (pass Retain first if you want to keep your own).
func FromArrowChunked ¶
FromArrowChunked wraps an existing *arrow.Chunked. The function retains a reference; the caller's reference is unaffected.
func FromChunked ¶
FromChunked wraps an existing *arrow.Chunked. The function retains a reference; the caller's reference is unaffected.
func FromFloat32 ¶
FromFloat32 builds a Series from a []float32.
func FromFloat64 ¶
FromFloat64 builds a Series from a []float64.
func FromInt64 ¶
FromInt64 builds a Series from a []int64. valid may be nil to mark every value as valid; otherwise len(valid) must equal len(values) and valid[i] true means values[i] is non-null.
func FromString ¶
FromString builds a Series from a []string.
func FromTime ¶
func FromTime(name string, values []int64, valid []bool, dt dtype.DType, opts ...Option) (*Series, error)
FromTime builds a time-of-day Series. The values carry a count of the dtype's own unit since midnight (e.g. for Time(Microsecond), value 3600*1_000_000 means 01:00:00.000000). Unit must agree with dt.Arrow()'s underlying Time32/Time64 resolution.
func FromUint32 ¶
FromUint32 builds a Series from a []uint32.
func FromUint64 ¶
FromUint64 builds a Series from a []uint64.
func New ¶
New builds a Series from one or more arrow.Array chunks of the same dtype. On success New consumes the caller's references to the input arrays; callers must not use or release them afterward. On error the caller retains ownership.
func (*Series) Abs ¶
Abs returns a new Series with the absolute value of every element. For unsigned integer dtypes this is an identity clone. For signed integers and floats, nulls are preserved. Mirrors polars' Series.abs().
func (*Series) All ¶
All returns true when every non-null element is truthy. Empty or all-null returns true (the vacuous-truth convention polars uses).
func (*Series) Any ¶
Any returns true when at least one non-null element is truthy. For numeric inputs, truthy means non-zero. Empty/all-null returns false.
func (*Series) ApplyFloat64 ¶
ApplyFloat64 is the f64 counterpart.
func (*Series) ApplyInt64 ¶
Apply maps a user function over non-null values, producing a new Series of the same dtype. Null positions pass through unchanged. The function is called dtype-specifically: an Int64 Series gets func(int64) int64, a String Series func(string) string, etc.
Pass the right-typed applier via ApplyInt64/ApplyFloat64/ApplyString /ApplyBool. This avoids an `any` boxing per row on hot paths.
func (*Series) ApplyString ¶
ApplyString is the utf8 counterpart.
func (*Series) ApproxNUnique ¶
ApproxNUnique estimates the distinct-value count using HyperLogLog- style bucketing over a 64-bit fingerprint. For small series this is exact; for larger series it's an O(n) approximation with <2% error at k=14 registers. Mirrors polars' approx_n_unique semantics.
func (*Series) Arctan2 ¶
Arctan2 returns atan2(s, other) element-wise. Both inputs must be numeric and the same length. Mirrors polars' arctan2.
func (*Series) ArgMin ¶
ArgMin returns the index of the smallest non-null value. For floats NaN is ignored. Empty or all-null input returns (-1, nil). Mirrors polars' Series.arg_min.
func (*Series) ArgSort ¶
ArgSort returns the permutation that would sort s ascending. Nulls are placed at the end. Mirrors polars' Series.arg_sort default.
func (*Series) ArgTrue ¶
ArgTrue returns a UInt64 Series of positions where s is true. s must be a boolean Series. Mirrors polars' arg_true.
func (*Series) ArgUnique ¶
ArgUnique returns the indices of the first occurrence of each distinct value in s. Order preserves first-seen. Mirrors polars' arg_unique.
func (*Series) BackwardFill ¶
BackwardFill is ForwardFill in reverse: nulls are replaced by the next non-null value. Trailing nulls (after the last value) remain null.
func (*Series) Chunk ¶
Chunk returns the chunk at index i.
For a single-chunk Series this is a direct O(1) accessor. For a multi-chunk Series (e.g. the output of a zero-copy Shift), Chunk(0) transparently consolidates all chunks into one and caches the result in s.data so subsequent calls are O(1). This keeps the 300+ legacy callers that assume single-chunk behaviour correct when they see a Series produced by a multi-chunk path. The consolidation pays the O(n) copy that the zero-copy path deferred - same model polars uses for its chunked arrays.
Not thread-safe: Series has never been, and adding a mutex would burden every single-chunk read. Concurrent Chunk(0) calls on a multi-chunk Series are a caller bug; callers that want safety should rechunk up-front via s.Consolidated().
func (*Series) Chunked ¶
Chunked returns the underlying *arrow.Chunked. The caller must Retain it if it intends to outlive the Series.
func (*Series) Chunks ¶
Chunks returns the underlying chunk slice. Do not mutate. The returned arrays share ownership with this Series; if you retain them independently, call Retain on each.
func (*Series) Clip ¶
Clip bounds each element into [lo, hi]. The bounds are interpreted in the Series' dtype: callers pass a typed scalar via ClipInt64 or ClipFloat64 when they want dtype-specific bounds without overflow. Nil bounds (math.Inf for lo / +math.Inf for hi) leave that side open.
func (*Series) Clone ¶
Clone returns a Series that shares the underlying data with s. Both values must be Released independently.
func (*Series) Consolidated ¶
Consolidated returns an arrow.Array that holds every row of this Series in a single contiguous chunk. When the Series already has one chunk the call is a retain-only no-op; with multiple chunks it concatenates via array.Concatenate. The caller owns the returned array and must Release it.
Needed whenever an op can accept a Series that might have been produced by a zero-copy multi-chunk path (Shift and friends) and the consumer's kernel assumes contiguous values. compute.extractChunk already does this internally, so compute kernels don't need to call this - it's for external consumers and tests.
func (*Series) Covariance ¶
Covariance returns the sample covariance (ddof=1) between s and other. Requires numeric inputs and equal length. Mirrors polars' pl.cov(..., ddof=1).
func (*Series) CumCount ¶
CumCount returns a running count of non-null values. Output is an int64 Series with no nulls.
func (*Series) CumMin ¶
CumMin returns a running minimum: out[i] = min(src[0..=i]). Nulls are skipped (out stays at the previous running min when the current row is null), matching polars. Empty input → empty output.
func (*Series) CumProd ¶
CumProd returns a running product. Polars widens to the input's numeric dtype; we emit float64 for simplicity and overflow safety.
func (*Series) CumSum ¶
CumSum returns a new Series where out[i] = sum of s[0..i] (inclusive), skipping nulls as if they were zero. Mirrors polars' Series.cum_sum(). If the source has any nulls, the output at those positions is also null: a null cannot be "summed into" a running total without a reset rule, and polars preserves nulls here.
Only numeric dtypes (int64, int32, float64) are supported; other dtypes return an error.
func (*Series) Diff ¶
Diff returns the elementwise difference s[i] - s[i-periods]. The first periods positions are null. Negative periods diff against a future row (tail becomes null). Mirrors polars Series.diff().
Only numeric dtypes are supported.
func (*Series) DropNulls ¶
DropNulls returns a new Series with every null position removed. Preserves order. If the input has no nulls, a clone is returned. Mirrors polars Series.drop_nulls().
func (*Series) EWMMean ¶
EWMMean returns the adjusted exponentially-weighted moving mean with smoothing parameter alpha (0 < alpha <= 1). The recursion matches polars' default `ewm_mean(alpha=alpha, adjust=True)`:
y[t] = sum_{i=0..t} w_i * x_i / sum_{i=0..t} w_i
w_i = (1 - alpha)^(t - i)
Null values do not contribute; their output slot is null. Supported dtypes: Int64, Int32, Float64, Float32. Integer inputs are promoted to float64.
func (*Series) EWMVar ¶
EWMVar returns the adjusted exponentially-weighted moving (sample) variance using West's online recursion.
func (*Series) Entropy ¶
Entropy returns the Shannon entropy of s' value distribution: the sum of -p_i * log(p_i) across distinct non-null values, where p_i is the empirical probability. `base` selects the log base (e for natural entropy, 2 for bits).
func (*Series) Equal ¶
Equal reports whether two Series are element-wise equal (names + values + null pattern + dtypes). NaN != NaN. Mirrors the polars `series_equal` function.
func (*Series) ExtendConstant ¶
ExtendConstant returns a Series with n copies of v appended at the tail. The result dtype is unchanged. Mirrors polars' Series.extend_ constant.
func (*Series) FillNan ¶
FillNan replaces every NaN in a float Series with value. Nulls are preserved. Mirrors polars Series.fill_nan(value).
Non-float inputs are cloned unchanged: NaN is a float-only value and applying fill_nan to an integer column is a no-op in polars.
func (*Series) FillNull ¶
FillNull returns a new Series where every null is replaced with the given value. The value's Go type must match the Series dtype; mixing dtypes returns an error rather than silently coercing. Mirrors polars Series.fill_null(value).
If the source has no nulls, a clone is returned: the method is always safe to call and always returns a fully-valid Series.
func (*Series) FirstNonNull ¶
FirstNonNull returns the first non-null value in the Series and its index, or (nil, -1, nil) when the series is all-null or empty.
func (*Series) Format ¶
func (s *Series) Format(opts SeriesFormatOptions) string
Format renders the Series as a polars-style single-column box table.
func (*Series) ForwardFill ¶
ForwardFill propagates the last non-null value forward into nulls. limit caps the number of consecutive fills (0 = unlimited), matching polars' fill_null(strategy="forward", limit=N). Mirrors Series.forward_fill().
Leading nulls (before any value) remain null. Types without a meaningful "previous" reading (numeric, bool, string) are supported; other dtypes return an error.
func (*Series) Hash ¶
Hash returns a uint64 Series of FNV-64a hashes of each non-null value. Null positions are preserved as null in the output. Deterministic but not cryptographic. Matches polars' Series.hash in spirit; the exact hash value differs since polars uses xxhash.
func (*Series) Head ¶
Head returns the first n rows. Negative n is interpreted polars- style: keep all rows except the last |n|.
func (*Series) IndexOf ¶
IndexOf returns the first index where the Series equals v, or -1 if no such position exists. Non-matching dtypes return an error.
func (*Series) IsDuplicated ¶
IsDuplicated is the complement of IsUnique: true where a value occurs more than once.
func (*Series) IsFinite ¶
IsFinite returns a boolean mask of finite (non-NaN, non-±Inf) floats. Non-float numeric dtypes are always finite.
func (*Series) IsFirstDistinct ¶
IsFirstDistinct returns a boolean mask where true marks the first occurrence of each distinct value. Polars-compatible.
func (*Series) IsInfinite ¶
IsInfinite returns a boolean mask of ±Inf floats. Non-float numeric dtypes always return false.
func (*Series) IsLastDistinct ¶
IsLastDistinct marks the last occurrence.
func (*Series) IsNaN ¶
IsNaN returns a boolean Series with true at every NaN (float dtypes only). Null inputs produce null outputs. Non-float dtypes return an all-false mask with the same null pattern. Mirrors polars' is_nan.
func (*Series) IsNull ¶
IsNull returns a new boolean Series where each position is true iff the corresponding value in s is null. Mirrors polars Series.is_null. The returned Series has no nulls itself.
func (*Series) IsSorted ¶
func (s *Series) IsSorted(order SortedOrder) (bool, error)
IsSorted reports whether s is sorted in the requested order. Nulls are treated as "last" (polars' default null placement in sort), so any null inside an otherwise-sorted prefix makes the result false. Mirrors polars' Series.is_sorted(descending=..., strict=...).
Returns (false, error) only for unsupported dtypes; for supported dtypes IsSorted never errors.
func (*Series) IsUnique ¶
IsUnique returns a boolean Series where true marks rows whose value occurs exactly once in the input. Nulls form their own equivalence class: multiple nulls mark each other as non-unique.
func (*Series) Kurtosis ¶
Kurtosis returns the excess kurtosis of the non-null values. Matches polars' default (bias=True, fisher=True): m4/m2^2 - 3, where m_k = (1/n)*sum((x-mean)^k). Call KurtosisUnbiased for the sample-size-corrected scipy formula.
func (*Series) KurtosisUnbiased ¶
KurtosisUnbiased returns the bias-corrected (scipy bias=False) excess kurtosis.
func (*Series) List ¶
List returns the list namespace. Every method on the returned ListOps fails with a clear error when the underlying Series is not list-typed.
func (*Series) Log ¶
Log returns natural log element-wise as a float64 Series. Negative inputs produce NaN, zero produces -Inf.
func (*Series) Mean ¶
Mean returns the arithmetic mean of non-null elements. Returns (NaN, nil) when the series is empty or all-null.
func (*Series) Median ¶
Median returns the 50-percentile. For even-count data, polars averages the two middle values (linear interpolation), which we follow.
func (*Series) Min ¶
Min returns the minimum non-null value as a float64 for numeric dtypes. Empty or all-null input returns (NaN, nil). Float NaN is ignored unless all non-null values are NaN.
func (*Series) Mode ¶
Mode returns the most frequent value(s). Ties produce multiple rows. Nulls are counted only if all non-null values would tie with the null count. Empty input returns an empty Series of the same dtype.
func (*Series) PctChange ¶
PctChange returns the percent change between each row and the previous row (or between row i and row i-periods for non-default periods). Output is float64; leading rows are null.
func (*Series) PeakMax ¶
PeakMax returns a boolean Series whose i-th position is true when s[i] is strictly greater than both neighbours. Edges are always false. Mirrors polars' peak_max.
func (*Series) PeakMin ¶
PeakMin returns a boolean Series whose i-th position is true when s[i] is strictly less than both neighbours.
func (*Series) PearsonCorr ¶
PearsonCorr returns the Pearson correlation coefficient between s and other. Length mismatch or an all-null pair returns NaN.
func (*Series) Pow ¶
Pow raises each element to an integer power. Integer output for integer input, float for float.
func (*Series) Product ¶
Product returns the product of non-null elements as float64. Empty/all-null returns 1 (the identity), matching polars.
func (*Series) Quantile ¶
Quantile returns the q-th quantile (0..1) using linear interpolation. Empty/all-null returns NaN.
func (*Series) Rank ¶
func (s *Series) Rank(method RankMethod, opts ...Option) (*Series, error)
Rank returns a float64 Series of per-row ranks. Ascending by default; tie handling follows `method`. Nulls stay null.
func (*Series) Rechunk ¶
Rechunk returns a single-chunk clone of s. When s already has one chunk the call is a retain-only passthrough; otherwise the chunks are concatenated via arrow.Concatenate. Matches polars' series `rechunk()` and is the common preparatory step before crossing the FFI boundary or handing the Series to a kernel that assumes a single backing buffer.
func (*Series) Release ¶
func (s *Series) Release()
Release drops this Series' reference to its chunked data. After Release the Series must not be used.
func (*Series) Retain ¶
func (s *Series) Retain()
Retain increments this Series' reference count. Use this when sharing a Series across goroutines that each manage their own Release.
func (*Series) Reverse ¶
Reverse returns a new Series with elements in reverse order. Mirrors polars' Series.reverse.
func (*Series) RollingMax ¶
func (s *Series) RollingMax(opts RollingOptions, callerOpts ...Option) (*Series, error)
RollingMax returns the rolling maximum.
func (*Series) RollingMean ¶
func (s *Series) RollingMean(opts RollingOptions, callerOpts ...Option) (*Series, error)
RollingMean returns the rolling average.
func (*Series) RollingMin ¶
func (s *Series) RollingMin(opts RollingOptions, callerOpts ...Option) (*Series, error)
RollingMin returns the rolling minimum.
func (*Series) RollingStd ¶
func (s *Series) RollingStd(opts RollingOptions, callerOpts ...Option) (*Series, error)
RollingStd returns the rolling sample standard deviation (ddof=1).
func (*Series) RollingSum ¶
func (s *Series) RollingSum(opts RollingOptions, callerOpts ...Option) (*Series, error)
RollingSum returns a rolling sum using a right-aligned window of size opts.WindowSize. Rows where the valid-count is less than MinPeriods emit null.
func (*Series) RollingVar ¶
func (s *Series) RollingVar(opts RollingOptions, callerOpts ...Option) (*Series, error)
RollingVar returns the rolling sample variance (ddof=1).
func (*Series) Round ¶
Round rounds each value to the given number of decimal places. decimals=0 rounds to integer. Integers are a no-op clone. NaN stays NaN; ±Inf stays unchanged.
func (*Series) Sample ¶
Sample returns n randomly selected rows, with or without replacement. seed controls the PRNG; 0 asks for a fresh PCG source.
func (*Series) SampleFrac ¶
func (s *Series) SampleFrac(fraction float64, withReplacement bool, seed uint64, opts ...Option) (*Series, error)
SampleFrac returns a Series of floor(fraction * Len()) rows drawn without replacement by default. Mirrors the polars sample(fraction=) convenience.
func (*Series) SearchSorted ¶
SearchSorted returns the insertion index for v such that the resulting slice would remain sorted (ascending). The Series is assumed to already be sorted. Mirrors polars' Series.search_sorted with "left" side semantics: the first position i where s[i] >= v.
func (*Series) Shift ¶
Shift returns a new Series shifted by periods positions. Positive periods shift values down (forward in time): out[i] = s[i-periods]. Negative periods shift up (backward in time).
Positions that fall outside the source become null. The returned Series always has the same length as the input. Mirrors polars' Series.shift(periods).
Zero-copy implementation: the result is a 2-chunk ChunkedArray composed of an all-null prefix/suffix plus a zero-copy arrow slice of the source chunk(s). No data is memcpy'd. This matches polars' shift, which achieves the same via metadata-only chunk manipulation.
Downstream kernels that need a single contiguous chunk pay an O(n) rechunk cost on first access (polars does the same). Kernels that iterate via extractChunk or handle chunks natively see no penalty.
func (*Series) Shuffle ¶
Shuffle returns a Series containing the same values in a random order. Equivalent to Sample(Len(), false, seed).
func (*Series) Sign ¶
Sign returns -1, 0, or 1 per element. The output dtype matches the input (int64 → int64, float64 → float64). NaN input yields NaN.
func (*Series) Skew ¶
Skew returns the skewness of the non-null values. Matches polars' default (bias=True): the simple moment ratio g1 = m3 / m2^(3/2), where m_k = (1/n)*sum((x - mean)^k). Call SkewUnbiased for the Fisher-Pearson adjusted form.
func (*Series) SkewUnbiased ¶
SkewUnbiased returns the Fisher-Pearson (bias=False) skewness.
func (*Series) Slice ¶
Slice returns a Series containing [offset, offset+length). Data buffers are shared; no data is copied.
func (*Series) Sqrt ¶
Sqrt returns a new float64 Series with the element-wise square root. Integer inputs are promoted to float64. Negative inputs produce NaN.
func (*Series) Std ¶
Std returns the sample standard deviation (ddof=1). Use Var for the variance and `StdPopulation` if polars-compatible population stats are wanted (we follow polars' default).
func (*Series) Str ¶
Str returns the string-ops view over s. Call Str() once per pipeline step; the returned value is cheap (no allocation).
func (*Series) Struct ¶
Struct returns the struct namespace. Every method fails with a clear error when the underlying Series is not struct-typed.
func (*Series) Sum ¶
Sum returns the sum of non-null elements as a float64 (for numeric dtypes) or errors on non-numeric dtypes. Polars returns the sum as the same dtype for integers; we always widen to float64 for simplicity and overflow safety. Empty or all-null input returns 0.
For bool, Sum returns the count of true values.
func (*Series) ToArrow ¶
ToArrow returns the Series' first chunk as an arrow.Array. The returned array shares memory with the Series; call Retain if you want to outlive the Series. Single-chunk series (the current norm) return their sole backing array.
For multi-chunk inputs use ToArrowChunked.
func (*Series) ToArrowChunked ¶
ToArrowChunked returns the underlying *arrow.Chunked with a fresh reference. Safe to keep after the Series is released. This is the zero-copy interop point for cross-language Arrow pipelines.
func (*Series) TopK ¶
TopK returns the k largest non-null elements, sorted descending. Stable across ties. Empty/all-null returns an empty Series.
func (*Series) Unique ¶
Unique returns a new Series containing the distinct non-null values of s in first-occurrence order. Nulls are collapsed into a single null entry appended to the end if present. Mirrors polars' Series.unique(maintain_order=true).
For int64 and float64 inputs an open-addressing int64 hash backs the dedup so the operation is O(n). Other dtypes fall back to a map.
func (*Series) ValueCounts ¶
ValueCounts returns two parallel Series: the distinct values in s (in first-occurrence order) and their uint32 counts. Nulls are dropped (like polars value_counts by default). Callers wanting a DataFrame can pass both Series to dataframe.New.
Output column names: the value Series takes s.Name(), the count Series is named "count". Sorted by descending count when sortByCount is true.
type SeriesFormatOptions ¶
type SeriesFormatOptions struct {
MaxRows int // -1 = no limit
MaxCellRune int // -1 = no truncation
}
SeriesFormatOptions controls Series pretty-printing.
func DefaultSeriesFormatOptions ¶
func DefaultSeriesFormatOptions() SeriesFormatOptions
DefaultSeriesFormatOptions matches polars' default: show up to 10 rows with head/tail ellipsis when longer.
type SortedOrder ¶
type SortedOrder int
SortedOrder controls what IsSorted considers a "sorted" series.
const ( // SortedAscending accepts non-decreasing sequences (ties allowed). SortedAscending SortedOrder = iota // SortedDescending accepts non-increasing sequences (ties allowed). SortedDescending // SortedStrictAscending requires strict ordering (no ties). SortedStrictAscending // SortedStrictDescending requires strict reverse ordering (no ties). SortedStrictDescending )
type StrOps ¶
type StrOps struct {
// contains filtered or unexported fields
}
StrOps exposes string-specific operations on a utf8 Series. Access via Series.Str(). A Series.Str() on a non-string dtype returns an ops handle whose methods return errors.
Mirrors polars' `s.str.*` namespace. Each method returns a fresh Series and does not mutate the receiver. The underlying string buffer is not shared: results are freshly allocated so the caller owns their buffers (Release when done).
func (StrOps) After ¶
After returns the substring after the first occurrence of sep. Strings that don't contain sep come back as the empty string.
func (StrOps) Before ¶
Before returns the substring preceding the first occurrence of sep in each string. If sep is not found, the whole original string is returned. Useful for parsing: s.Str().Before("@") on an email column gives the local part.
func (StrOps) Concat ¶
Concat appends suffix to every non-null string. Name-level: Series.Str().Concat(" suffix") returns `value + " suffix"`.
func (StrOps) Contains ¶
Contains reports whether each string contains needle (plain substring, not regex). Uses Go's SIMD-accelerated strings.Contains; for regex patterns, use ContainsRegex. Null inputs yield null outputs.
Empty-needle fast path: every non-null row is true.
func (StrOps) ContainsRegex ¶
ContainsRegex returns a boolean Series: true where the value matches the compiled regex pattern. Nulls stay null.
func (StrOps) CountMatches ¶
CountMatches counts the number of (non-overlapping) occurrences of needle in each string.
func (StrOps) CountMatchesRegex ¶
CountMatchesRegex returns the number of non-overlapping matches of pattern in each string.
func (StrOps) Extract ¶
Extract returns the capture group `group` (0 = entire match) from the first regex match per cell. Cells that don't match become null. Mirrors polars' str.extract(pattern, group_index).
func (StrOps) Find ¶
Find returns the byte offset of the first occurrence of needle in each string, or -1 when not found. Null inputs stay null. Matches polars str.find (byte-indexed).
func (StrOps) Head ¶
Head returns a Series holding the first n characters of each string. n is counted in runes (to match polars str.head semantics) for non-ASCII input; ASCII-only columns short-circuit to byte-level. Negative n means "all but the last |n| characters".
ASCII fast path: since each UTF-8 code point is exactly one byte in ASCII, rune count equals byte count. We can slice offsets directly without decoding.
func (StrOps) IsNumeric ¶
IsNumeric returns a boolean mask that is true when the string parses as a decimal number (integer or float). Convenience for cleaning scraped data.
func (StrOps) LStrip ¶
LStrip removes leading characters matching cutset. When cutset is empty, removes whitespace.
func (StrOps) LenBytes ¶
LenBytes returns the byte-length of each string as an int64 Series. Nulls propagate to null outputs.
Zero-read implementation: each row's byte length is the difference of adjacent offsets. We never touch the values buffer, so the hot loop is two int32 loads + subtract + store, trivially SIMD-friendly and predictable for the branch predictor.
func (StrOps) LenChars ¶
LenChars returns the rune-count of each string as an int64 Series. For ASCII-only input this equals LenBytes.
func (StrOps) Like ¶
Like returns a boolean Series that is true where the SQL-style pattern matches the row. % matches zero or more characters, _ matches exactly one; \ escapes the next character.
The compiler classifies the pattern shape and routes literal-only forms to specialised predicates: bare `%X%` to strings.Contains, `X%` to HasPrefix, `%X` to HasSuffix, `X` to equality. These close over the raw []byte (or string) without going through the full likePattern.match machinery, eliminating the closure-dispatch overhead the general path pays. Null inputs stay null.
func (StrOps) NotLike ¶
NotLike is the inverse of Like. Same specialisation ladder, with the terminal negation folded into each specialised closure so the hot loop still makes a single predicate call.
func (StrOps) PadStart ¶
PadStart pads each string on the left with pad (repeated as needed) up to totalLen runes. Strings already ≥ totalLen are left as-is.
func (StrOps) Replace ¶
Replace replaces the first occurrence of old with new in each string. Use ReplaceAll for global replacement.
func (StrOps) ReplaceAll ¶
ReplaceAll replaces every occurrence of old.
func (StrOps) ReplaceRegex ¶
ReplaceRegex replaces every regex-matching substring with repl.
func (StrOps) Slice ¶
Slice returns runes[start:start+length] of each string. length=-1 means "to the end". start may be negative (polars convention: count from end).
func (StrOps) SplitExact ¶
SplitExact splits each cell by sep and returns a List<String> Series where each row is the full slice of components for that row. Null input rows produce null output rows. Empty strings produce a single-element list of "".
Mirrors polars' `s.str.split(sep)`. For the positional-pluck variant use SplitN or SplitExactNullShort.
func (StrOps) SplitExactNullShort ¶
SplitExactNullShort returns the n-th split component, or null if the cell has fewer than n+1 components. Use SplitN for the empty-string fallback variant.
func (StrOps) SplitN ¶
SplitN returns the n-th (0-indexed) split segment of each string, using sep as the separator. When a cell doesn't have enough segments the output is null. Equivalent to polars' `str.split_exact(sep, n).struct.field("field_n")`.
func (StrOps) SplitNth ¶
SplitNth returns the nth field (0-indexed) produced by splitting each string on sep. If n is out of range the empty string is emitted. This stops short of the full polars str.split (which returns a List column); SplitNth is the common case.
func (StrOps) SplitWide ¶
SplitWide returns one string Series per split field up to maxN. The result is a DataFrame-friendly per-field projection: for s.Str().SplitWide("-", 3) on "a-b-c-d", output has 3 columns named `<series-name>_0`, `_1`, `_2` containing ["a"], ["b"], ["c-d"]. If the caller asks for more fields than any row has, extra columns are null-padded.
func (StrOps) StartsWith ¶
StartsWith reports whether each string begins with prefix. Direct byte comparison via strings.HasPrefix; no allocation per row.
func (StrOps) StripPrefix ¶
StripPrefix removes prefix from each string that starts with it; strings that don't are left unchanged.
func (StrOps) StripSuffix ¶
StripSuffix is the symmetric counterpart.
func (StrOps) Tail ¶
Tail returns the last n characters of each string. Symmetric to Head. Negative n means "all but the first |n| characters".
func (StrOps) Title ¶
Title capitalises the first letter of each word. Go's stdlib has no direct equivalent of Python's str.title; we roll a simple version that splits on whitespace.
func (StrOps) ToLowercase ¶
ToLowercase is the symmetric counterpart; ASCII lowercase is `b | 0x20` for A..Z, unchanged for everything else.
func (StrOps) ToUppercase ¶
ToUppercase uppercases every character.
Three tiers. Columns whose entire values buffer is ASCII route to caseFoldAsciiWhole, which folds the whole buffer in one tight loop and reuses the input's offsets verbatim (no per-row dispatch). Non-ASCII columns fall back to stdlib strings.ToUpper via mapString; they're the slow path but correctness-preserving.
type StructOps ¶
type StructOps struct {
// contains filtered or unexported fields
}
StructOps is the namespace for operations over struct-typed Series. Reach it via `s.Struct()`. Mirrors polars' `s.struct.*` surface.
func (StructOps) Field ¶
Field returns the named field of the struct as a new top-level Series. Struct-level nulls propagate into the child's validity so downstream kernels see consistent null rows.
func (StructOps) FieldNames ¶
FieldNames returns the struct's field names in declaration order.
Source Files
¶
- agg.go
- arrow_interop.go
- bitmap.go
- cumulative.go
- cumulative_extra.go
- direct.go
- dropnulls.go
- ewm.go
- fillextra.go
- fillnull.go
- format.go
- issorted.go
- list.go
- math.go
- math_extra.go
- more.go
- null.go
- position.go
- position_extra.go
- rolling.go
- series.go
- shift.go
- stats.go
- str.go
- str_more.go
- str_regex.go
- strfast.go
- strhead.go
- strlike.go
- struct.go
- transform.go
- unique.go
- validity.go
- valuecounts.go