Help us shape the future of Go! Take the 2026 Go Developer Survey

selector

package
v0.6.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package selector picks a frame's columns by what they are, as Polars' selectors do: by type, by name, by place, and the unions, intersections, differences and complements of those (step 322). The set algebra is named, Union and Complement where Polars writes | and ~, so a selector's complement is never mistaken for an expression's negation.

lf.Select(selector.Numeric().Difference(selector.ByName("id")).Expr()) // every number but id
lf.WithColumns(selector.Float().Exclude("price").Expr().Round(2))      // each float but price, rounded

A selector is resolved against the frame's schema when the query is planned, so one written selector serves any schema. Each answers in the schema's order but ByName and ByIndex, which answer in the order written, as Polars' do; a combined selector answers in the schema's order. A selector that selects nothing selects nothing, as Polars': no error, but where a name or a place is asked for that the frame lacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Selector

type Selector struct {
	// contains filtered or unexported fields
}

Selector is a choice of columns, resolved against a schema.

func All

func All() Selector

All is every column, and Empty none.

func Alpha

func Alpha() Selector

Alpha is the columns whose name is letters alone, Digit digits alone and Alphanumeric either, any script's, as Polars' with ascii_only false.

func Alphanumeric

func Alphanumeric() Selector

func Array

func Array() Selector

func Binary

func Binary() Selector

func Boolean

func Boolean() Selector

func ByDType

func ByDType(types ...ursus.DataType) Selector

ByDType is the columns of the types given, exactly: a Datetime's unit and zone both.

func ByIndex

func ByIndex(indices ...int) Selector

ByIndex is the columns at the places given, in that order, a negative place from the end; one past either end is an error. First and Last are the first and the last column.

func ByName

func ByName(names ...string) Selector

ByName is the named columns, in the order named; one the frame lacks is an error.

func Categorical

func Categorical() Selector

Categorical selects the Categorical columns, Polars' cs.categorical(), which String does not, as Polars' cs.string() does not by default. New in 0.6.7.

func Contains

func Contains(subs ...string) Selector

func Date

func Date() Selector

func Datetime

func Datetime() Selector

func Decimal

func Decimal() Selector

func Digit

func Digit() Selector

func Duration

func Duration() Selector

func Empty

func Empty() Selector

func EndsWith

func EndsWith(suffixes ...string) Selector

func Enum

func Enum() Selector

func First

func First() Selector

func Float

func Float() Selector

Float is the float columns, and Decimal the Decimal ones.

func Integer

func Integer() Selector

Integer is the integer columns, SignedInteger the signed ones and UnsignedInteger the unsigned.

func Last

func Last() Selector

func List

func List() Selector

List is the List columns, Array the Array ones, Struct the Struct ones, and Nested any of them. Array is new in 0.6.7.

func Matches

func Matches(pattern string) Selector

Matches is the columns whose name the regular expression matches, anywhere in it, as Polars' matches; anchor it with ^ and $ for the whole name.

func Nested

func Nested() Selector

func Numeric

func Numeric() Selector

Numeric is the columns of numbers: integers, floats and Decimals.

func SignedInteger

func SignedInteger() Selector

func StartsWith

func StartsWith(prefixes ...string) Selector

StartsWith is the columns whose name starts with any of prefixes, EndsWith ends with any of suffixes, and Contains holds any of subs.

func String

func String() Selector

String is the text columns, Binary the binary ones, Boolean the Boolean and Enum the Enum.

func Struct

func Struct() Selector

func Temporal

func Temporal() Selector

Temporal is the columns of dates, instants, durations and times of day; Date, Datetime, Duration and Time each one kind, a Datetime of any unit and zone.

func Time

func Time() Selector

func UnsignedInteger

func UnsignedInteger() Selector

func (Selector) Complement

func (s Selector) Complement() Selector

Complement is every column s does not select, Polars' ~ of a selector.

func (Selector) Difference

func (s Selector) Difference(o Selector) Selector

Difference is the columns s selects and o does not, Polars' -.

func (Selector) Exclude

func (s Selector) Exclude(names ...string) Selector

Exclude is the columns s selects but the named ones, Polars' exclude: a name it does not select is passed over.

func (Selector) Expand

func (s Selector) Expand(schema *ursus.Schema) ([]string, error)

Expand is the names s selects in schema, in the order the expression would make them, as Polars' expand_selector: an unknown name or place, or a pattern that does not compile, is an error.

func (Selector) Expr

func (s Selector) Expr() ursus.Expr

Expr is the selector as an expression, a column each selected column, where an expression goes: Select, WithColumns, Agg, or a method of Expr's.

func (Selector) Intersect

func (s Selector) Intersect(o Selector) Selector

Intersect is the columns both select, Polars' &.

func (Selector) String

func (s Selector) String() string

String renders the selector, as Explain does.

func (Selector) SymmetricDifference

func (s Selector) SymmetricDifference(o Selector) Selector

SymmetricDifference is the columns one selects and the other does not, Polars' ^.

func (Selector) Union

func (s Selector) Union(o Selector) Selector

Union is the columns either selects, Polars' |.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL