Repository navigation
Releases
Polars wrapper library 0.6.1
Prebuilt libnanuq_ffi 0.6.1. Nanuq downloads these at compile time; see the README.
Nanuq 0.6
Nanuq 0.6 is "engine and edges": Polars' streaming engine and sinks, saved query plans, Binary and Decimal columns, Arrow memory shared with Nim and other libraries without copying, Excel, SQLite and cloud storage. It also adds thirty small functions from the new Polars coverage map and the ones the Nanuq Book ports still missed, and it now builds on the same Polars code as py-polars 2.1.0. The API choices are explained in Designing Nanuq 0.6.
The prebuilt Polars library is lib-v0.6.0, built from the Polars git tag py-2.1.0, and is downloaded automatically. Excel support comes from two pure-Rust crates compiled into it (calamine and rust_xlsxwriter): no Python and nothing extra to install.
Added
- Streaming:
collect(Engine.Streaming),collectAll(lfs, engine), and the sinkssinkParquet,sinkIpc,sinkCsv,sinkNdjsonto a file or to Hive-style folders withPartitionBy;lazy = truereturns the sink forcollectAll. - Saved query plans:
serialize/deserializefor LazyFrames and expressions (binary or JSON), plusmeta.eq,pop,isColumnSelection,isLiteral,treeFormat. - Binary and Decimal:
BinaryandDecimal(precision, scale)columns, thebinnamespace,str.encode,str.toDecimal, and thebitwise*expressions. - Arrow C Data Interface:
toArrow/fromArrowfor Series and frames, and zero-copyview(T)of numeric columns (for x in df.view("kg", float)).mapElementson numeric columns reads through views now. - Excel:
readExcel(sheet by name or index,headerRow,skipRowsafter the header as in Python,columns,schemaOverrides),readExcelSheets,writeExcel. - SQLite: optional module
nanuq/databasewithreadDatabase,readDatabaseUri,writeDatabase(needsnimble install db_connector). - Testing: module
nanuq/testingwithassertFrameEqual,assertSeriesEqualand theirNotEqualtwins. - Cloud storage: CSV, Parquet, IPC and NDJSON reads, scans, writes and sinks take
s3://,gs://,az://,hf://andhttps://URIs, withstorageOptions = {"aws_region": "eu-west-1"}(or credentials from the environment). - From the coverage map: empty frames (
newDataFrame(schema = {...}),clear),isClose,eqMissing, business days (dt.addBusinessDays,businessDayCount),timeRange,cumulativeEval,roundSigFigs,matchToSchema,mergeSorted,cacheandQueryOptFlags,str.normalize,readOds, IPC streams, table styles (setTblFormatting,setAsciiTables, ...) and more. - From the book ports: frame aggregations (
df.mean,df.nullCount, ...), group-by shortcuts (g.sum,g.head(2),g.len),for key, part in df.groupBy(...),select(...)without a frame,xor, operator methods (mul,sub, ...),joinWhere,intRanges,dateRanges,unstack,hist,rollingMap,append,remove,dtypeOf,scatter,fromEpoch,readParquetSchemaand more. - From the explainer:
bin.slice/head/tail/get,str.toInteger(base = 36), UInt64 values above 2^63,readCsv(quoteChar = none(char), encoding = CsvEncoding.Utf8Lossy, newColumns = [...]), androlling/groupByDynamicwithgroupBy = "store".
Changed
- Operators take selectors on either side (
all() > 0keeps each column's name), and comparisons with a value on the left are mirrored as in Python:0 < col("a")is nameda, notliteral. describeprints datetimes and the mean of dates as Python does (1986-09-04 00:00:00).- Polars 2: Nanuq builds on Polars at the py-polars 2.1.0 tag instead of the 0.55.2 crate, so results match Python. As in Polars 2,
profileandcat.getCategoriesare removed (compile-time errors that say what to use), CSV columns read without a header arecolumn_0,column_1, ...,topKvalues come in no particular order, and a lazy join withoutmaintainOrderdoes not keep the left order. DataFrame methods now run like Python's eager methods (in-memory engine), so their row order and error messages match py-polars;sampledefaults toshuffle = none, as in Polars. - Fixed:
cast,renameand CSV/JSON schema overrides could pass freed column names to Polars (wrong column, unstable Categorical codes);newColumnswithschemaOverridesnow uses the new names.
Known limitations
No plot namespace (nim-plotly and ggplotnim work with toSeq/toDatamancer), and SQLite only for databases.
Full details are in CHANGELOG.md.
What's Changed
- README: link the Above 4000 explainer by @pietroppeter in #61
- Nanuq 0.6: streaming, plans, Binary/Decimal, Arrow, Excel, SQLite, cloud, Polars py-2.1.0 pin, coverage wins (+ 0.6.0 bump) by @pietroppeter in #59
- Dev log: unify the posts and cross-link them by @pietroppeter in #62
- Prebuilt library sums for lib-v0.6.0 by @github-actions[bot] in #63
Full Changelog: v0.5.0...v0.6.0
Polars wrapper library 0.6.0
Prebuilt libnanuq_ffi 0.6.0. Nanuq downloads these at compile time; see the README.
v0.5.0
Nanuq 0.5 is "nested data and user code": a cell can now hold a list, a fixed-size array or a struct, Polars can call your Nim procs, and you can query frames with SQL and read and write JSON. That covers most of what the Nanuq Book still marked "not yet". The API choices (asStruct, typed mapElements, the SQL macro, how data types print) are explained in Designing Nanuq 0.5. The 0.5 explainer, "Above 4000", follows shortly.
The prebuilt Polars library is lib-v0.5.0 (Polars 0.55), downloaded automatically, with the list, array, struct, JSON and SQL features of Polars turned on.
Added
- Nested data types:
List(String),Array(Float64, 3),Struct({"x": Int64}). Nimseq,array[N, T], objects and named tuples map to them both ways: build columns innewDataFrame,seriesorlit(@[1, 2]), and read them back withtoList(seq[string])ortoList(MyObject), nulls included. - Lists: the
listnamespace (len,first,get,contains,join,sort, set operations,evalandaggwithelement(), ...),explodeandimplode,concatList,repeatBy. - Structs and arrays:
asStruct(...)(Python'spl.struct), thestructnamespace (field,unnest,renameFields,withFields,jsonEncode), frameunnest,Expr.valueCounts, and thearrnamespace. - Strings that give lists:
str.split,splitExact,splitn,extractAll,extractGroups,containsAny,replaceMany,extractMany,findMany,jsonDecode,jsonPathMatch. - JSON:
readJson,readNdjson,scanNdjson,writeJson,writeNdjson,toJson,toNdjson, with files or Nim streams. - SQL:
SQLContext(register,execute,tables),sqlContext(peaks, routes)naming tables after your variables,df.sql("SELECT ... FROM self")andsql(query, frames). - Nim callbacks: typed
mapElements(proc (x: int): string)(struct rows arrive as your object type),mapBatches,fold,reduce,cumFold,name.map,mapGroups. Nim exceptions becomeComputeError.mapElementsis 2-10x faster than py-polars'map_elements(benchmarks/), though native expressions stay faster. - Series namespaces:
s.list,s.struct,s.str,s.dt,s.arr,s.cat, ands.toHtmlfor notebooks. - Smaller functions asked for by the book and explainer ports:
over(mappingStrategy),shuffle,sample,hash,get,argTrue,upperBound/lowerBound,extendConstant,rle,reshape,entropy,len(),e.meta,equals,vstack/hstack/extend,update,upsample,partitionBy(asDict = true),estimatedSize,collectAll, frameinterpolate,fillNull(0),filter(a, b),cast({Float64: Float32}),explode("a", "b"), and columns fromint32,uint8,float32and the other sized numbers.
Breaking changes
$on a data type prints Nanuq code:Int64,List(String),Struct({"x": Int64}),DateTime(Milliseconds, "UTC"), instead of Polars' short names (i64). Schemas print the same way. Table headers,glimpseandtoHtmlkeepi64, as in Python.
Known limitations
Nanuq pins the newest Polars crate release (0.55.2), while py-polars 2.1.0 is built from a newer Polars commit. So a few things differ from Python 2.1: SQL table functions with named options (read_csv('f.csv', infer_schema => false)), hash values, the order of sample, and the type of SQL COUNT(*) (u32 instead of i64). Also missing: decimal and binary columns, streaming sinks and cloud storage.
Full details are in CHANGELOG.md.
What's Changed
- Dev log: Counting El Niños, the Nanuq 0.4 explainer by @pietroppeter in #55
- Nanuq 0.5: nested data and user code by @pietroppeter in #53
- Prepare the 0.5.0 release by @pietroppeter in #56
- Above 4000: the Nanuq 0.5 explainer (mountains and treks) by @pietroppeter in #57
- Prebuilt library sums for lib-v0.5.0 by @github-actions[bot] in #58
Full Changelog: v0.4.0...v0.5.0
Nanuq 0.4
Nanuq 0.4 is "a real Series, and shaping": about two hundred new functions for math, cumulative and rolling windows, ranking and recoding, horizontal functions and correlation, pivot and unpivot, time windows and as-of joins, plus a Series you can compute with, rows as Nim objects and Arraymancer tensors. The API choices, and what the El Niño explainer and the Nanuq Book ports changed, are explained in Designing Nanuq 0.4. The 0.4 explainer, "Counting El Niños", follows shortly.
The prebuilt Polars library is lib-v0.4.0 (Polars 0.55), downloaded automatically. It turns on many more Polars features than 0.3, so the download is larger.
Added
- Math:
sqrt,cbrt,exp,log(base),log10,log1p,sign,floor,ceil,clip, trigonometry,dot, and NaN/infinity checks (isNan,fillNan,dropNans,isFinite). - Order and accumulation:
shift,diff,pctChange,cumSum/cumProd/cumMin/cumMax/cumCount,rleId(number runs of equal values),peaks,product,mode,argMin/argMax,skew,kurtosis. - Windows:
rollingMeanand friends by rows,rollingMeanBy("day", 7.days)over time,ewmMean/ewmStd/ewmVar,interpolate,interpolateBy. - Values: Expr
sort,sortBy,head/tail/slice,gather,topK/topKBy,indexOf,searchSorted, distinct-value functions,replace({"a": "x"}),replaceStrict,cut/qcut(Enum results),valueCounts; frametopK/bottomK(k, by)returning whole rows, framegatherEvery. - Across columns:
sumHorizontal,maxHorizontaland friends,coalesce,intRange,linearSpace,repeat,corr(Pearson, Spearman),cov,any/allaggregations. - Reshaping:
pivot(withPivotAggor anelement()expression),unpivot,transpose,partitionBy,toDummies. - Time:
groupByDynamic("day", every = 1.months), the rolling group-by,joinAsof(backward, forward, nearest, with tolerance andby), anddate(col.year, col.month, 15)from parts. - Series:
df["anomaly"]is a Series with operators,filter, and every expression method (s.rollingMean(3)); aggregations give a one-value Series read withitem(float);lit(s)andwithColumns(s)put it back into a frame. - Rows as objects:
df.rows(T),iterRows(T),row(i, T)for objects and named tuples, andtoDataFrame(seq[T]). - Arraymancer: optional
import nanuq/arraymancerfortoTensor(Series, column or 2-D frame),toSeriesandtoDataFrame. - Conveniences:
select("a", "b")andgroupBy("a")with plain names,lit(nil)as Python'sNone(fillNan(nil)),setFloatPrecision/setConfig(floatPrecision = 2).
Breaking changes
- On a DataFrame,
groupBy(...).agg(...)(alsogroupByDynamicandrolling) returns a DataFrame, as in Python; drop the.collect. A leftover.collecton a DataFrame is a compile error with a hint. LazyFrame is unchanged. - Python's
methodparameter ishow:rank(how = Dense)(wasrankMethod),corr(a, b, how = Spearman),interpolate(how = Nearest). Positional calls are unchanged.
Known limitations
Compared with Polars, 0.4 has no List, Array or Struct columns (so no explode, unnest, str.split, Expr.valueCounts), no JSON, no Nim callbacks (mapElements) and no SQL. Those are the plan for 0.5. Strings in repeat need lit("x") because of std/strutils' repeat.
Full details are in CHANGELOG.md.
—-
auto generated:
What's Changed
- Nanuq 0.4: a real Series, and shaping by @pietroppeter in #51
- Prepare the 0.4.0 release by @pietroppeter in #52
- Prebuilt library sums for lib-v0.4.0 by @github-actions[bot] in #54
Full Changelog: v0.3.0...v0.4.0
Nanuq 0.3
Nanuq 0.3 adds the data types and functions real tables need: dates, datetimes, durations and times of day, string expressions, categoricals (a Nim enum is a Polars Enum), Parquet and Arrow IPC, typed errors, and glimpse/describe. The walkthrough is Aged 19, a look at the youngest winners in pro cycling. The API choices are explained in Designing Nanuq 0.3.
The prebuilt Polars library is lib-v0.3.0 (Polars 0.55), downloaded automatically. It is now built like py-polars, with nightly Rust, Polars' nightly feature and jemalloc. PDS-H at scale factor 1 drops from 13.6 s to 3.2 s on an M3 Pro, within 5% of py-polars.
Added
- Dates and times: Date, Datetime (with time unit and time zone), Duration and Time columns. They are built from Nanuq's
DateandTimeOfDayand from std/times'DateTimeandDuration(nanuq exports std/times). Also: casts and literals;dateRange,datetimeRangeandduration; parsing withstr.toDate,str.toDatetime,str.toTime,str.strptimeandreadCsv(tryParseDates = true); thedtnamespace for parts, formatting, truncation, offsets, time zones,combineand duration totals. - Strings: the
strnamespace (lenChars,toUppercase,stripChars,contains(pattern, literal),extract,replace,replaceAll,slice,padStart,zfill, thejoinaggregation,toTitlecase, ...),concatStrandformat("{} ({})", ...). Patterns are Rust regexes. - Categoricals:
CategoricalandEnum(["low", "high"]), and Nim enums as Polars Enums (cast(Monument),toList(df, "race", Monument),col.medal == Gold). Also thecatnamespace andExpr.toPhysical. - Files:
scanParquet,readParquet,writeParquet(withParquetCompression,compressionLevel,statistics,rowGroupSize),scanIpc,readIpcandwriteIpc. CSV, Parquet and IPC can also be read from a NimStream. - Inspection:
glimpse,describe(percentiles), and display settings:setTblRowsand the othersetTbl*setters,setConfig(...),resetConfig()and the scopedwithConfig(...): body. - Conveniences:
col.raceshorthand forcol("race"),col(someSeq), block syntax fornewDataFrame(name: [values]lines,nilfor missing values),Expr.nullCount,rank(Min, descending = true), andExpr.filter(predicate)for conditional aggregations. - Typed errors:
PolarsErrorwith Python's subtypes (ColumnNotFoundError,ComputeError,InvalidOperationError,SchemaError, ...).
Breaking changes
/is true division, as in Python Polars and Nim: integer columns divide to f64, and dividing by zero givesinforNaN.divstays floor division.toSeq(df, column, T)is renamedtoList, sosequtils.toSeqworks again with Nanuq imported.NanuqErroris renamedPolarsError. IO failures raise Nim'sIOError.- The native ABI passes data types as an
NqDtypeSpecstruct. This only matters if you link your ownlibnanuq_ffi.
Known limitations
Compared with Polars, 0.3 has no List or Struct columns (so no str.split), no groupByDynamic or rolling windows, no pivot, and no writing to streams. str.toTitlecase needs a library built with the nightly feature, as the prebuilt ones are.
Full details are in CHANGELOG.md.
Github generated changes
- Implement add-spec-examples: runnable examples in the specs by @pietroppeter in #43
- BACKLOG: integer
/design question, block syntax for newDataFrame by @pietroppeter in #44 - Dev log: Designing Nanuq 0.3 and 0.2 by @pietroppeter in #45
- Nanuq 0.3 by @pietroppeter in #47
- Prepare the 0.3.0 release by @pietroppeter in #48
- Backlog: Performance area (nightly Rust + polars/nightly + jemalloc closes the gap with Python Polars) by @pietroppeter in #46
- Prebuilt library sums for lib-v0.3.0 by @github-actions[bot] in #49
- Dev log: Aged 19, the Nanuq 0.3 explainer by @pietroppeter in #50
Full Changelog: v0.2.0...v0.3.0
Polars wrapper library 0.5.0
Prebuilt libnanuq_ffi 0.5.0. Nanuq downloads these at compile time; see the README.
Polars wrapper library 0.4.0
Prebuilt libnanuq_ffi 0.4.0. Nanuq downloads these at compile time; see the README.
Polars wrapper library 0.3.0
Prebuilt libnanuq_ffi 0.3.0. Nanuq downloads these at compile time; see the README.
Nanuq 0.2
Nanuq 0.2 covers what a first real analysis needs: data types and casts, joins and concatenation, frame verbs, conditional and window expressions, column selectors, and CSV options with lazy scanCsv. The walkthrough is The great polar bear census. The prebuilt Polars library is lib-v0.2.0 (Polars 0.55), downloaded automatically.
Added
- Data types:
DataTypeconstants with Polars names (Int64,String, ...),dtypes,schema,collectSchema, andcasttaking a Nim type orDataTypevalues, strict by default (#26) - Joins and concat:
join(inner, left, right, full, semi, anti, cross) withvalidate,coalesce,maintainOrder;concatvertical, horizontal or diagonal (#28) - Frame verbs:
drop,rename,tail,slice,reverse,withRowIndex,unique, multi-keysortwithnullsLast,samplewithseed,setRandomSeed(#30, #31) - Expressions:
`when`/then/otherwiseand thechoosemacro,isIn,isBetween,mod,div,^,abs,round,median,var,quantile,len,fillNull(Forward),forwardFill,backwardFill, and windows withover(#33) - Column selectors:
col(SomeNumber)and other Nim typeclasses,col(int),col("a", "b"),all(),exclude,name.suffix/name.prefix(#35) - CSV: lazy
scanCsvwith globs, and read options (separator,nullValues,schemaOverrides,skipRows,nRows,columns, ...) and write options (quoteStyle,floatPrecision,decimalComma, ...) (#37) - API conventions: Polars names in camelCase, option values as pure enums with Rust Polars names (#28)
Breaking
dtype(df, col)returns aDataTypeinstead of a string;$gives the old string (#26)DataTypeKindis a pure enum with Polars names (DataTypeKind.Int64) (#28)
Known limitations
No dates, datetimes or categoricals yet, no string functions, and CSV is the only file format.
Full changelog: CHANGELOG.md
All PRs
- Backlog: discuss whether to use Atlas by @pietroppeter in #24
- Proposal: add-datatype-and-cast (DataType, schemas, cast) by @pietroppeter in #25
- DataType, schemas and cast (implements add-datatype-and-cast) by @pietroppeter in #26
- Proposal: add-joins-and-concat (and the option-value convention) by @pietroppeter in #27
- Add joins and concatenation by @pietroppeter in #28
- Propose add-frame-verbs by @pietroppeter in #29
- Add frame verbs by @pietroppeter in #30
- Add setRandomSeed and plain int seed for sample by @pietroppeter in #31
- Propose add-expr-essentials by @pietroppeter in #32
- Add expression essentials by @pietroppeter in #33
- Propose add-column-selectors by @pietroppeter in #34
- Add column selectors by @pietroppeter in #35
- Propose add-csv-options-and-scan by @pietroppeter in #36
- Implement add-csv-options-and-scan by @pietroppeter in #37
- Add the 0.2 explainer post: the great polar bear census by @pietroppeter in #38
- Prepare the 0.2.0 release by @pietroppeter in #39
- README: link the Nanuq Book by @pietroppeter in #40
- Propose add-spec-examples (OpenSpec change) by @pietroppeter in #41
- Prebuilt library sums for lib-v0.2.0 by @github-actions[bot] in #42
Full Changelog: v0.1.0...v0.2.0