Repository navigation
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