Skip to content

Nanuq 0.3

Choose a tag to compare

@pietroppeter pietroppeter released this 01 Nov 02:31
· 119 commits to main since this release
da038b1

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 Date and TimeOfDay and from std/times' DateTime and Duration (nanuq exports std/times). Also: casts and literals; dateRange, datetimeRange and duration; parsing with str.toDate, str.toDatetime, str.toTime, str.strptime and readCsv(tryParseDates = true); the dt namespace for parts, formatting, truncation, offsets, time zones, combine and duration totals.
  • Strings: the str namespace (lenChars, toUppercase, stripChars, contains(pattern, literal), extract, replace, replaceAll, slice, padStart, zfill, the join aggregation, toTitlecase, ...), concatStr and format("{} ({})", ...). Patterns are Rust regexes.
  • Categoricals: Categorical and Enum(["low", "high"]), and Nim enums as Polars Enums (cast(Monument), toList(df, "race", Monument), col.medal == Gold). Also the cat namespace and Expr.toPhysical.
  • Files: scanParquet, readParquet, writeParquet (with ParquetCompression, compressionLevel, statistics, rowGroupSize), scanIpc, readIpc and writeIpc. CSV, Parquet and IPC can also be read from a Nim Stream.
  • Inspection: glimpse, describe(percentiles), and display settings: setTblRows and the other setTbl* setters, setConfig(...), resetConfig() and the scoped withConfig(...): body.
  • Conveniences: col.race shorthand for col("race"), col(someSeq), block syntax for newDataFrame (name: [values] lines, nil for missing values), Expr.nullCount, rank(Min, descending = true), and Expr.filter(predicate) for conditional aggregations.
  • Typed errors: PolarsError with 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 gives inf or NaN. div stays floor division.
  • toSeq(df, column, T) is renamed toList, so sequtils.toSeq works again with Nanuq imported.
  • NanuqError is renamed PolarsError. IO failures raise Nim's IOError.
  • The native ABI passes data types as an NqDtypeSpec struct. This only matters if you link your own libnanuq_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