pandas for Go

github.com/malcolmston/pandas

pandas-style DataFrames and data analysis for Go.

 GitHubports pandas-dev/pandas

A from-scratch, standard-library-only Go take on pandas: a named, typed one-dimensional Series with first-class missing-value (NA) support, and an ordered DataFrame of equal-length columns built from column maps, slices of structs, or CSV. On top of those two types sit the everyday analysis verbs — column and row selection (Select, Col, ILoc, Loc, FilterFunc), transformation (WithColumn, SortBy, FillNA, DropNA, Describe), GroupBy aggregations (Sum, Mean, Min, Max, Count, Std) and inner/left Merge. Everything is built on encoding/csv, sort, strconv and reflect — no cgo, no third-party modules — and every operation produces a stable, reproducible ordering with missing values sorted last.

Install

shell
$ go get github.com/malcolmston/pandas

Quick start

main.go
import "github.com/malcolmston/pandas"

df, _ := pandas.FromMap(map[string][]any{
    "city":  {"NYC", "LA", "NYC", "LA"},
    "month": {"Jan", "Jan", "Feb", "Feb"},
    "sales": {100.0, 80.0, 120.0, 90.0},
}, []string{"city", "month", "sales"})

hot := df.FilterFunc(func(r pandas.Row) bool {
    v, ok := r.Float("sales")
    return ok && v >= 100
})
gb, _ := df.GroupBy("city")
means, _ := gb.Mean("sales")
fmt.Print(hot, means, df.Describe())

Features

  • Series — a named, typed 1-D column (Float64/Int64/String/Bool + Object) with an index and first-class IsNA missing-value support
  • DataFrame construction from column maps (FromMap), slices of structs (FromRecords), Series (NewDataFrame) or CSV (ReadCSV/ReadCSVFile)
  • Selection & indexing — columns via Select/Col/Drop, rows via ILoc/Head/Tail, labels via Loc, masks via Filter/FilterFunc
  • Transformation — WithColumn, Rename, Apply/Map, SortBy on one or more keys, and NA handling with FillNA/DropNA
  • GroupBy partitioning with deterministic ordering and the Sum, Mean, Min, Max, Count, Std aggregations (or the general Agg)
  • Merge — inner and left joins on a shared key (InnerJoin/LeftJoin), with _left/_right suffixes for colliding columns
  • Describe — count / mean / std / min / max for every numeric column, plus Unique and ValueCounts
  • Zero dependencies — pure Go standard library (encoding/csv, sort, strconv, reflect), with stable, reproducible ordering throughout
pandas