Skip to content

Releases

Polars wrapper library 0.6.1

Choose a tag to compare

@github-actions github-actions released this 06 Nov 05:04
44eaf86

Prebuilt libnanuq_ffi 0.6.1. Nanuq downloads these at compile time; see the README.

Nanuq 0.6

Choose a tag to compare

@pietroppeter pietroppeter released this 02 Nov 09:28
dc8579e

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 sinks sinkParquet, sinkIpc, sinkCsv, sinkNdjson to a file or to Hive-style folders with PartitionBy; lazy = true returns the sink for collectAll.
  • Saved query plans: serialize/deserialize for LazyFrames and expressions (binary or JSON), plus meta.eq, pop, isColumnSelection, isLiteral, treeFormat.
  • Binary and Decimal: Binary and Decimal(precision, scale) columns, the bin namespace, str.encode, str.toDecimal, and the bitwise* expressions.
  • Arrow C Data Interface: toArrow/fromArrow for Series and frames, and zero-copy view(T) of numeric columns (for x in df.view("kg", float)). mapElements on numeric columns reads through views now.
  • Excel: readExcel (sheet by name or index, headerRow, skipRows after the header as in Python, columns, schemaOverrides), readExcelSheets, writeExcel.
  • SQLite: optional module nanuq/database with readDatabase, readDatabaseUri, writeDatabase (needs nimble install db_connector).
  • Testing: module nanuq/testing with assertFrameEqual, assertSeriesEqual and their NotEqual twins.
  • Cloud storage: CSV, Parquet, IPC and NDJSON reads, scans, writes and sinks take s3://, gs://, az://, hf:// and https:// URIs, with storageOptions = {"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, cache and QueryOptFlags, 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, readParquetSchema and 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 = [...]), and rolling/groupByDynamic with groupBy = "store".

Changed

  • Operators take selectors on either side (all() > 0 keeps each column's name), and comparisons with a value on the left are mirrored as in Python: 0 < col("a") is named a, not literal.
  • describe prints 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, profile and cat.getCategories are removed (compile-time errors that say what to use), CSV columns read without a header are column_0, column_1, ..., topK values come in no particular order, and a lazy join without maintainOrder does 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; sample defaults to shuffle = none, as in Polars.
  • Fixed: cast, rename and CSV/JSON schema overrides could pass freed column names to Polars (wrong column, unstable Categorical codes); newColumns with schemaOverrides now 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

Choose a tag to compare

@github-actions github-actions released this 02 Nov 07:23
3ce0f9a

Prebuilt libnanuq_ffi 0.6.0. Nanuq downloads these at compile time; see the README.

v0.5.0

Choose a tag to compare

@pietroppeter pietroppeter released this 01 Nov 18:01
ec6ed17

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}). Nim seq, array[N, T], objects and named tuples map to them both ways: build columns in newDataFrame, series or lit(@[1, 2]), and read them back with toList(seq[string]) or toList(MyObject), nulls included.
  • Lists: the list namespace (len, first, get, contains, join, sort, set operations, eval and agg with element(), ...), explode and implode, concatList, repeatBy.
  • Structs and arrays: asStruct(...) (Python's pl.struct), the struct namespace (field, unnest, renameFields, withFields, jsonEncode), frame unnest, Expr.valueCounts, and the arr namespace.
  • 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") and sql(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 become ComputeError. mapElements is 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, and s.toHtml for 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, frame interpolate, fillNull(0), filter(a, b), cast({Float64: Float32}), explode("a", "b"), and columns from int32, uint8, float32 and 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, glimpse and toHtml keep i64, 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

Choose a tag to compare

@pietroppeter pietroppeter released this 01 Nov 14:34
c7f8746

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: rollingMean and 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; frame topK/bottomK(k, by) returning whole rows, frame gatherEvery.
  • Across columns: sumHorizontal, maxHorizontal and friends, coalesce, intRange, linearSpace, repeat, corr (Pearson, Spearman), cov, any/all aggregations.
  • Reshaping: pivot (with PivotAgg or an element() expression), unpivot, transpose, partitionBy, toDummies.
  • Time: groupByDynamic("day", every = 1.months), the rolling group-by, joinAsof (backward, forward, nearest, with tolerance and by), and date(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 with item(float); lit(s) and withColumns(s) put it back into a frame.
  • Rows as objects: df.rows(T), iterRows(T), row(i, T) for objects and named tuples, and toDataFrame(seq[T]).
  • Arraymancer: optional import nanuq/arraymancer for toTensor (Series, column or 2-D frame), toSeries and toDataFrame.
  • Conveniences: select("a", "b") and groupBy("a") with plain names, lit(nil) as Python's None (fillNan(nil)), setFloatPrecision / setConfig(floatPrecision = 2).

Breaking changes

  • On a DataFrame, groupBy(...).agg(...) (also groupByDynamic and rolling) returns a DataFrame, as in Python; drop the .collect. A leftover .collect on a DataFrame is a compile error with a hint. LazyFrame is unchanged.
  • Python's method parameter is how: rank(how = Dense) (was rankMethod), 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

Choose a tag to compare

@pietroppeter pietroppeter released this 01 Nov 02:31
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

Polars wrapper library 0.5.0

Choose a tag to compare

@github-actions github-actions released this 01 Nov 17:15
90ec67a

Prebuilt libnanuq_ffi 0.5.0. Nanuq downloads these at compile time; see the README.

Polars wrapper library 0.4.0

Choose a tag to compare

@github-actions github-actions released this 01 Nov 12:50
b7157ec

Prebuilt libnanuq_ffi 0.4.0. Nanuq downloads these at compile time; see the README.

Polars wrapper library 0.3.0

Choose a tag to compare

@github-actions github-actions released this 01 Nov 01:36
a1af577

Prebuilt libnanuq_ffi 0.3.0. Nanuq downloads these at compile time; see the README.

Nanuq 0.2

Choose a tag to compare

@pietroppeter pietroppeter released this 31 Oct 18:34
920b160

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: DataType constants with Polars names (Int64, String, ...), dtypes, schema, collectSchema, and cast taking a Nim type or DataType values, strict by default (#26)
  • Joins and concat: join (inner, left, right, full, semi, anti, cross) with validate, coalesce, maintainOrder; concat vertical, horizontal or diagonal (#28)
  • Frame verbs: drop, rename, tail, slice, reverse, withRowIndex, unique, multi-key sort with nullsLast, sample with seed, setRandomSeed (#30, #31)
  • Expressions: `when`/then/otherwise and the choose macro, isIn, isBetween, mod, div, ^, abs, round, median, var, quantile, len, fillNull(Forward), forwardFill, backwardFill, and windows with over (#33)
  • Column selectors: col(SomeNumber) and other Nim typeclasses, col(int), col("a", "b"), all(), exclude, name.suffix/name.prefix (#35)
  • CSV: lazy scanCsv with 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 a DataType instead of a string; $ gives the old string (#26)
  • DataTypeKind is 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

Full Changelog: v0.1.0...v0.2.0