Documentation
¶
Overview ¶
Package golars is the top-level facade that re-exports the most common types and helpers from the sub-packages so that a single
import "github.com/Gaurav-Gosain/golars"
brings DataFrame, Series, expression helpers, and I/O entry points into scope. The sub-packages stay the canonical homes; this file is sugar so users don't need to remember which package holds what.
polars users will recognise most of the names: `golars.Col`, `golars.Lit`, `golars.Sum`, `golars.ReadCSV`, `golars.Concat`, etc.
Index ¶
- Constants
- Variables
- func NewIPCStreamReader(r io.Reader, opts ...ipc.Option) (*ipc.StreamReader, error)
- func NewIPCStreamWriter(w io.Writer, schemaFrame *DataFrame, opts ...ipc.Option) (*ipc.StreamWriter, error)
- func When(pred Expr) expr.WhenBuilder
- func WriteCSV(df *DataFrame, path string, opts ...iocsv.Option) error
- func WriteIPC(df *DataFrame, path string, opts ...ipc.Option) error
- func WriteJSON(df *DataFrame, path string) error
- func WriteNDJSON(df *DataFrame, path string) error
- func WriteParquet(df *DataFrame, path string, opts ...parquet.Option) error
- type DType
- type DataFrame
- func Concat(frames ...*DataFrame) (*DataFrame, error)
- func FromMap(data map[string]any, order []string) (*DataFrame, error)
- func NewDataFrame(cols ...*Series) (*DataFrame, error)
- func ReadCSV(path string, opts ...iocsv.Option) (*DataFrame, error)
- func ReadCSVReader(r io.Reader, opts ...iocsv.Option) (*DataFrame, error)
- func ReadIPC(path string, opts ...ipc.Option) (*DataFrame, error)
- func ReadJSON(path string, opts ...iojson.Option) (*DataFrame, error)
- func ReadNDJSON(path string, opts ...iojson.Option) (*DataFrame, error)
- func ReadParquet(path string, opts ...parquet.Option) (*DataFrame, error)
- func SelectExpr(ctx context.Context, df *DataFrame, exprs ...Expr) (*DataFrame, error)
- func WithColumnsExpr(ctx context.Context, df *DataFrame, exprs ...Expr) (*DataFrame, error)
- type Expr
- func BackwardFill(col string, limit int) Expr
- func Coalesce(exprs ...Expr) Expr
- func Col(name string) Expr
- func ConcatStr(sep string, exprs ...Expr) Expr
- func Count(col string) Expr
- func FillNan(col string, v float64) Expr
- func First(col string) Expr
- func ForwardFill(col string, limit int) Expr
- func IntRange(start, end, step int64) Expr
- func Last(col string) Expr
- func Lit(v any) Expr
- func LitBool(v bool) Expr
- func LitFloat64(v float64) Expr
- func LitInt64(v int64) Expr
- func LitString(v string) Expr
- func Max(col string) Expr
- func Mean(col string) Expr
- func Median(col string) Expr
- func Min(col string) Expr
- func NullCount(col string) Expr
- func Ones(n int) Expr
- func Std(col string) Expr
- func Sum(col string) Expr
- func Var(col string) Expr
- func Zeros(n int) Expr
- type JoinType
- type LazyFrame
- func Lazy(df *DataFrame) LazyFrame
- func ScanCSV(path string, opts ...iocsv.Option) LazyFrame
- func ScanIPC(path string, opts ...ipc.Option) LazyFrame
- func ScanJSON(path string, opts ...iojson.Option) LazyFrame
- func ScanNDJSON(path string, opts ...iojson.Option) LazyFrame
- func ScanParquet(path string, opts ...parquet.Option) LazyFrame
- type Series
- func AllHorizontal(ctx context.Context, df *DataFrame, cols ...string) (*Series, error)
- func AnyHorizontal(ctx context.Context, df *DataFrame, cols ...string) (*Series, error)
- func Filter(ctx context.Context, s *Series, mask *Series) (*Series, error)
- func FromBool(name string, v []bool, valid []bool) (*Series, error)
- func FromFloat32(name string, v []float32, valid []bool) (*Series, error)
- func FromFloat64(name string, v []float64, valid []bool) (*Series, error)
- func FromInt32(name string, v []int32, valid []bool) (*Series, error)
- func FromInt64(name string, v []int64, valid []bool) (*Series, error)
- func FromString(name string, v []string, valid []bool) (*Series, error)
- func MaxHorizontal(ctx context.Context, df *DataFrame, cols ...string) (*Series, error)
- func MeanHorizontal(ctx context.Context, df *DataFrame, cols ...string) (*Series, error)
- func MinHorizontal(ctx context.Context, df *DataFrame, cols ...string) (*Series, error)
- func SumHorizontal(ctx context.Context, df *DataFrame, cols ...string) (*Series, error)
- func Take(ctx context.Context, s *Series, indices []int) (*Series, error)
Constants ¶
const ( InnerJoin = dataframe.InnerJoin LeftJoin = dataframe.LeftJoin CrossJoin = dataframe.CrossJoin )
Join-type constants surfaced at the top level.
Variables ¶
var ( Int64DType = dtype.Int64 Int32DType = dtype.Int32 Int16DType = dtype.Int16 Int8DType = dtype.Int8 UInt64DType = dtype.Uint64 UInt32DType = dtype.Uint32 UInt16DType = dtype.Uint16 UInt8DType = dtype.Uint8 Float64DType = dtype.Float64 Float32DType = dtype.Float32 StringDType = dtype.String BoolDType = dtype.Bool DateDType = dtype.Date BinaryDType = dtype.Binary )
DTypes namespace: golars.Int64(), golars.String(), etc., matching polars' `pl.Int64`. Calling the function returns a DType value.
Functions ¶
func NewIPCStreamReader ¶
NewIPCStreamReader wraps r as a streaming Arrow IPC reader.
func NewIPCStreamWriter ¶
func NewIPCStreamWriter(w io.Writer, schemaFrame *DataFrame, opts ...ipc.Option) (*ipc.StreamWriter, error)
NewIPCStreamWriter wraps w as a streaming Arrow IPC writer. Use for multi-batch pipelines or cross-language streaming over a socket.
func When ¶
func When(pred Expr) expr.WhenBuilder
When starts a when/then/otherwise conditional expression.
func WriteCSV ¶
WriteCSV serialises a DataFrame to a CSV file at path.
Default writer emits a header row and quotes only fields that contain the delimiter, a quote, or a newline. Pass iocsv.WithDelimiter to use TSV (`'\t'`) or regional separators.
func WriteNDJSON ¶
WriteNDJSON writes df as newline-delimited JSON to a file.
Types ¶
type DataFrame ¶
DataFrame is the eager columnar table type. See package github.com/Gaurav-Gosain/golars/dataframe for the full API.
func FromMap ¶
FromMap builds a DataFrame from a column-name → slice map. order determines output column order (nil → alphabetical). Supported slice types mirror dataframe.FromMap.
func NewDataFrame ¶
NewDataFrame builds a DataFrame from the given Series columns. Equivalent to dataframe.New.
func ReadCSV ¶
ReadCSV reads a CSV file into a DataFrame.
Inference runs on the header + first rows: numeric columns become i64/f64, text becomes utf8. Pass iocsv.WithNullValues to treat specific tokens as nulls (empty string is a common choice to match polars defaults).
Uses context.Background; for cancellable reads call iocsv.ReadFile directly.
Example:
df, err := golars.ReadCSV("people.csv",
iocsv.WithNullValues(""), // empty field -> null
iocsv.WithDelimiter(';'), // European CSV
)
if err != nil { log.Fatal(err) }
defer df.Release()
fmt.Println(df.Schema())
func ReadCSVReader ¶
ReadCSVReader reads a CSV stream from an io.Reader. Useful for http bodies, stdin, or embedded fixtures via strings.NewReader.
Example:
resp, _ := http.Get("https://example.com/data.csv")
defer resp.Body.Close()
df, err := golars.ReadCSVReader(resp.Body)
func ReadNDJSON ¶
ReadNDJSON reads a newline-delimited JSON file.
func ReadParquet ¶
ReadParquet reads a Parquet file by path.
func SelectExpr ¶
SelectExpr evaluates the given expressions against df and returns a new DataFrame holding their outputs in order. Equivalent to `golars.Lazy(df).Select(exprs...).Collect(ctx)` but reads more naturally for one-shot eager use.
func WithColumnsExpr ¶
WithColumnsExpr evaluates the given expressions and attaches their outputs to df as additional columns, returning a new DataFrame. Equivalent to `golars.Lazy(df).WithColumns(exprs...).Collect(ctx)`.
type Expr ¶
Expr is the expression AST used to describe computations on columns. Built via Col, Lit, When, and fluent methods.
func BackwardFill ¶
BackwardFill is sugar for Col(col).BackwardFill(limit).
func ForwardFill ¶
ForwardFill is sugar for Col(col).ForwardFill(limit).
func LitFloat64 ¶
type JoinType ¶
JoinType enumerates join kinds: golars.InnerJoin, golars.LeftJoin, golars.CrossJoin.
type LazyFrame ¶
LazyFrame is the deferred-execution pipeline handle. See package github.com/Gaurav-Gosain/golars/lazy.
func ScanNDJSON ¶
ScanNDJSON returns a LazyFrame backed by a newline-delimited JSON file.
type Series ¶
Series is a named, chunked column. See package github.com/Gaurav-Gosain/golars/series.
func AllHorizontal ¶
AllHorizontal returns a boolean Series that is true iff every boolean column is true at that row.
func AnyHorizontal ¶
AnyHorizontal is the disjunctive counterpart of AllHorizontal.
func Filter ¶
Filter runs a compute-level filter on a series + mask. Convenience that avoids importing compute for one-line use.
func FromInt64 ¶
FromInt64 / FromFloat64 / FromString / FromBool are shortcuts to construct a Series from a native Go slice without remembering which sub-package exports each builder.
func MaxHorizontal ¶
MaxHorizontal returns a Series of row-wise maxima.
func MeanHorizontal ¶
MeanHorizontal returns a Series of row-wise means.
func MinHorizontal ¶
MinHorizontal returns a Series of row-wise minima.
func SumHorizontal ¶
SumHorizontal returns a Series of row-wise sums. See DataFrame.SumHorizontal for details.
Directories
¶
| Path | Synopsis |
|---|---|
|
bench
|
|
|
pds-h/cmd/pdsh
command
Command pdsh runs one or more PDS-H / TPC-H queries against a directory of parquet tables and emits per-run timings to bench/pds-h/output/timings.csv in the upstream polars-benchmark schema.
|
Command pdsh runs one or more PDS-H / TPC-H queries against a directory of parquet tables and emits per-run timings to bench/pds-h/output/timings.csv in the upstream polars-benchmark schema. |
|
pds-h/gen
command
Command gen writes a tiny synthetic lineitem.parquet with just enough columns and row count for local Q1/Q6 development.
|
Command gen writes a tiny synthetic lineitem.parquet with just enough columns and row count for local Q1/Q6 development. |
|
pds-h/queries
Package queries holds the golars implementations of the PDS-H / TPC-H query set.
|
Package queries holds the golars implementations of the PDS-H / TPC-H query set. |
|
Package browse provides an interactive TUI DataFrame viewer.
|
Package browse provides an interactive TUI DataFrame viewer. |
|
cmd
|
|
|
bench
command
Command bench runs the same workloads the polars harness runs and emits JSON with matching schema.
|
Command bench runs the same workloads the polars harness runs and emits JSON with matching schema. |
|
golars
command
Command golars is an interactive REPL for exploring DataFrames with golars.
|
Command golars is an interactive REPL for exploring DataFrames with golars. |
|
golars-kernel
command
Command golars-kernel is a Jupyter kernel for the golars `.glr` scripting language.
|
Command golars-kernel is a Jupyter kernel for the golars `.glr` scripting language. |
|
golars-lsp
command
Command golars-lsp is a minimal Language Server for golars .glr scripts.
|
Command golars-lsp is a minimal Language Server for golars .glr scripts. |
|
golars-mcp
command
Command golars-mcp is a Model Context Protocol server that exposes a read-only subset of golars as tools an LLM host (Claude Desktop, Cursor, Windsurf, ...) can invoke.
|
Command golars-mcp is a Model Context Protocol server that exposes a read-only subset of golars as tools an LLM host (Claude Desktop, Cursor, Windsurf, ...) can invoke. |
|
profiled-bench
command
profiled-bench runs a subset of the compare4 workloads with a CPU profile attached so we can see where real time goes across the benchmark suite, not just one workload in isolation.
|
profiled-bench runs a subset of the compare4 workloads with a CPU profile attached so we can see where real time goes across the benchmark suite, not just one workload in isolation. |
|
Package compute holds the vectorized kernel library.
|
Package compute holds the vectorized kernel library. |
|
Package dataframe defines DataFrame, an ordered collection of equal-length Series.
|
Package dataframe defines DataFrame, an ordered collection of equal-length Series. |
|
Package dtype defines the logical data types used by golars.
|
Package dtype defines the logical data types used by golars. |
|
Package eval evaluates expr.Expr trees against a DataFrame.
|
Package eval evaluates expr.Expr trees against a DataFrame. |
|
examples
|
|
|
arrow_interop
command
Arrow interop: DataFrame ↔ arrow.RecordBatch / arrow.Table.
|
Arrow interop: DataFrame ↔ arrow.RecordBatch / arrow.Table. |
|
basic
command
Build a DataFrame from slices, then take the head, filter, and sort.
|
Build a DataFrame from slices, then take the head, filter, and sort. |
|
coalesce_concat
command
Coalesce + ConcatStr + IntRange - polars-style constructors.
|
Coalesce + ConcatStr + IntRange - polars-style constructors. |
|
coalesce_concat/generic
command
Typed-column variant of ./examples/coalesce_concat.
|
Typed-column variant of ./examples/coalesce_concat. |
|
csv
command
Write a DataFrame to CSV and read it back.
|
Write a DataFrame to CSV and read it back. |
|
csv_url
command
Fetch a CSV from an http(s) URL.
|
Fetch a CSV from an http(s) URL. |
|
describe
command
DataFrame.Describe: summary statistics for every column.
|
DataFrame.Describe: summary statistics for every column. |
|
expressions
command
Column expressions used in select/with_columns.
|
Column expressions used in select/with_columns. |
|
expressions/generic
command
Typed-column variant of ./examples/expressions.
|
Typed-column variant of ./examples/expressions. |
|
fill_strategies
command
FillNull, ForwardFill, BackwardFill, FillNan.
|
FillNull, ForwardFill, BackwardFill, FillNan. |
|
groupby
command
Group by a key column and run per-group aggregations.
|
Group by a key column and run per-group aggregations. |
|
groupby/generic
command
Typed-column variant of ./examples/groupby.
|
Typed-column variant of ./examples/groupby. |
|
horizontal
command
Row-wise aggregates: SumHorizontal, MeanHorizontal, MinHorizontal.
|
Row-wise aggregates: SumHorizontal, MeanHorizontal, MinHorizontal. |
|
ipc_streaming
command
Write + read an Arrow IPC stream (cross-language binary format).
|
Write + read an Arrow IPC stream (cross-language binary format). |
|
join
command
Inner and left joins across two DataFrames.
|
Inner and left joins across two DataFrames. |
|
json
command
Parse JSON (array of objects) into a DataFrame and write it back.
|
Parse JSON (array of objects) into a DataFrame and write it back. |
|
lazy
command
Build and collect a lazy pipeline: filter -> groupby -> sort.
|
Build and collect a lazy pipeline: filter -> groupby -> sort. |
|
lazy/generic
command
Typed-column variant of ./examples/lazy.
|
Typed-column variant of ./examples/lazy. |
|
ndjson
command
Parse newline-delimited JSON (one object per line) into a DataFrame.
|
Parse newline-delimited JSON (one object per line) into a DataFrame. |
|
over_window
command
Window functions via Expr.Over(keys...).
|
Window functions via Expr.Over(keys...). |
|
over_window/generic
command
Typed-column variant of ./examples/over_window.
|
Typed-column variant of ./examples/over_window. |
|
parquet
command
Write a DataFrame to Parquet and read it back.
|
Write a DataFrame to Parquet and read it back. |
|
pivot
command
Pivot: long → wide reshape.
|
Pivot: long → wide reshape. |
|
profiler
command
Attach a profiler to a lazy plan and print per-node timings.
|
Attach a profiler to a lazy plan and print per-node timings. |
|
profiler/generic
command
Typed-column variant of ./examples/profiler.
|
Typed-column variant of ./examples/profiler. |
|
regex_strings
command
Regex + string ops: Extract, ContainsRegex, SplitN. Run: go run ./examples/regex_strings
|
Regex + string ops: Extract, ContainsRegex, SplitN. Run: go run ./examples/regex_strings |
|
rolling
command
Rolling sum / mean / std on a single-column time series.
|
Rolling sum / mean / std on a single-column time series. |
|
rolling/generic
command
Typed-column variant of ./examples/rolling.
|
Typed-column variant of ./examples/rolling. |
|
scan_pushdown
command
Lazy scan with predicate + projection pushdown.
|
Lazy scan with predicate + projection pushdown. |
|
scan_pushdown/generic
command
Typed-column variant of ./examples/scan_pushdown.
|
Typed-column variant of ./examples/scan_pushdown. |
|
script
command
Shows how to drive a golars pipeline from a script file via the public script package.
|
Shows how to drive a golars pipeline from a script file via the public script package. |
|
script/transpiled/agg
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/branching
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/demo
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/derived
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/join
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/multisource
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/nulls
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/pipeline
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/regex
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
script/transpiled/rolling
command
Code generated by `golars transpile`.
|
Code generated by `golars transpile`. |
|
sql_session
command
Register in-memory DataFrames and run SQL against them.
|
Register in-memory DataFrames and run SQL against them. |
|
stats
command
Stats: skew, kurtosis, corr, cov, approx_n_unique.
|
Stats: skew, kurtosis, corr, cov, approx_n_unique. |
|
streaming
command
Run a pipeline through the streaming/morsel engine.
|
Run a pipeline through the streaming/morsel engine. |
|
streaming/generic
command
Typed-column variant of ./examples/streaming.
|
Typed-column variant of ./examples/streaming. |
|
topk_pipe
command
TopK / BottomK / Pipe - nicer alternatives to Sort+Head.
|
TopK / BottomK / Pipe - nicer alternatives to Sort+Head. |
|
transpose_unpivot
command
Transpose and Unpivot (melt).
|
Transpose and Unpivot (melt). |
|
when_then
command
Conditional expressions with when().then().otherwise().
|
Conditional expressions with when().then().otherwise(). |
|
when_then/generic
command
Typed-column variant of ./examples/when_then.
|
Typed-column variant of ./examples/when_then. |
|
Package expr defines the golars expression AST.
|
Package expr defines the golars expression AST. |
|
internal
|
|
|
assert
Package assert provides runtime invariant checks for internal callers.
|
Package assert provides runtime invariant checks for internal callers. |
|
intmap
Package intmap provides a fast, purpose-built open-addressing hash map keyed on int64 with int32 values.
|
Package intmap provides a fast, purpose-built open-addressing hash map keyed on int64 with int32 values. |
|
mempool
Package mempool owns the process-global pooled arrow allocator shared by hot-loop kernels across compute, series, dataframe, and lazy.
|
Package mempool owns the process-global pooled arrow allocator shared by hot-loop kernels across compute, series, dataframe, and lazy. |
|
pool
Package pool provides goroutine-pool primitives used by compute kernels and the in-memory executor.
|
Package pool provides goroutine-pool primitives used by compute kernels and the in-memory executor. |
|
testutil
Package testutil provides test helpers for the golars module.
|
Package testutil provides test helpers for the golars module. |
|
io
|
|
|
clipboard
Package clipboard reads and writes DataFrames to the OS clipboard as CSV text.
|
Package clipboard reads and writes DataFrames to the OS clipboard as CSV text. |
|
csv
Package csv reads and writes RFC 4180 CSV using arrow-go's csv package.
|
Package csv reads and writes RFC 4180 CSV using arrow-go's csv package. |
|
ipc
Package ipc reads and writes the Arrow IPC stream format.
|
Package ipc reads and writes the Arrow IPC stream format. |
|
json
Package json reads and writes JSON and newline-delimited JSON (NDJSON), mirroring polars' pl.read_json / pl.read_ndjson / pl.write_json.
|
Package json reads and writes JSON and newline-delimited JSON (NDJSON), mirroring polars' pl.read_json / pl.read_ndjson / pl.write_json. |
|
parquet
Package parquet reads and writes Parquet files using arrow-go's pqarrow bridge.
|
Package parquet reads and writes Parquet files using arrow-go's pqarrow bridge. |
|
sql
Package sql reads golars DataFrames from any database/sql source.
|
Package sql reads golars DataFrames from any database/sql source. |
|
jupyter
|
|
|
render
Package render produces multi-mimetype representations of golars values for Jupyter and other notebook frontends.
|
Package render produces multi-mimetype representations of golars values for Jupyter and other notebook frontends. |
|
Package lazy provides the lazy query planner, optimizer, and executor.
|
Package lazy provides the lazy query planner, optimizer, and executor. |
|
Package repl is a reusable building block for terminal REPLs with inline ghost-text completions, persistent history, and a non-TTY fallback for piped input and scripting.
|
Package repl is a reusable building block for terminal REPLs with inline ghost-text completions, persistent history, and a non-TTY fallback for piped input and scripting. |
|
Package schema defines the Schema type, an ordered, immutable collection of named column dtypes.
|
Package schema defines the Schema type, an ordered, immutable collection of named column dtypes. |
|
Package script runs a very small pipe-style language against any backend that implements the Executor interface.
|
Package script runs a very small pipe-style language against any backend that implements the Executor interface. |
|
exprparse
Package exprparse turns a short text expression into an expr.Expr.
|
Package exprparse turns a short text expression into an expr.Expr. |
|
predparse
Package predparse parses the `.filter` predicate DSL used by the golars REPL, the script runner, and the glr-to-Go transpiler into an expr.Expr tree.
|
Package predparse parses the `.filter` predicate DSL used by the golars REPL, the script runner, and the glr-to-Go transpiler into an expr.Expr tree. |
|
transpile
Package transpile converts a .glr script into a self-contained Go program that reproduces the pipeline using the golars library API.
|
Package transpile converts a .glr script into a self-contained Go program that reproduces the pipeline using the golars library API. |
|
Package selector builds column-set predicates for DataFrame operations.
|
Package selector builds column-set predicates for DataFrame operations. |
|
Package series defines Series, a named, chunked, nullable column.
|
Package series defines Series, a named, chunked, nullable column. |
|
Package sql is a tiny SQL frontend for golars.
|
Package sql is a tiny SQL frontend for golars. |
|
Package stream provides the morsel-driven streaming executor.
|
Package stream provides the morsel-driven streaming executor. |









