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