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/pandasQuick 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-classIsNAmissing-value supportDataFrameconstruction from column maps (FromMap), slices of structs (FromRecords), Series (NewDataFrame) or CSV (ReadCSV/ReadCSVFile)- Selection & indexing — columns via
Select/Col/Drop, rows viaILoc/Head/Tail, labels viaLoc, masks viaFilter/FilterFunc - Transformation —
WithColumn,Rename,Apply/Map,SortByon one or more keys, and NA handling withFillNA/DropNA GroupBypartitioning with deterministic ordering and theSum,Mean,Min,Max,Count,Stdaggregations (or the generalAgg)Merge— inner and left joins on a shared key (InnerJoin/LeftJoin), with_left/_rightsuffixes for colliding columnsDescribe— count / mean / std / min / max for every numeric column, plusUniqueandValueCounts- Zero dependencies — pure Go standard library (
encoding/csv,sort,strconv,reflect), with stable, reproducible ordering throughout