Registered StackHub users may elect to receive email notifications whenever a new package version is released.
There are 2 watchers.
The NREL Utility extension provides a variety of missing utility functions for the Axon programming language.
Regarding Log4j Vulnerability: nrelUtilityExt is an Axon function resource extension and includes no Fantom or Java code. It is not affected by the Log4j vulnerability.
The union, intersect, and setDiff functions provide set operations for lists and dicts modeled on the equivalent functions in the R programming language. They complement the core function merge.
The NREL Utility extension includes a set of functions that implement SQL-style joins for grids, modeled closely on the join functions included in the dplyr package for R. Each join function has the general form *Join(a, b, by, opts)
, in which a
and b
are grids to join, by
specifies the column(s) to use to join the grids, and opts
is a dict of control options.
Six types of joins are available:
a
where there are matching values in b
and all columns from a
and b
a
and all columns from a
and b
b
and all columns from a
and b
a
and b
a
where there are matching values in b
, keeping columns from a
onlya
where there are not matching values in b
, keeping columns from a
onlyThe *Join
functions accept the following parameters:
by
is null (the default), then *Join
will perform a natural join, using columns with names common to both a
and b
. by
may also be:
{x:y, ...}
where each key name x
is a column name in a
and each key value y
(which must be a string) is a corresponding column name in b
The *Join
functions support the following options:
keep
: String specifying how to handle conflicting values in non-joined duplicate columns in a
and b
:
"a"
: Values from a
overwrite values from b
"b"
: Values from b
overwrite values from a
"both"
: Keeps values from both a
and b
, disambiguated by suffix"neither"
or "drop"
: Drops keys with conflicting values (replaces with null)"na"
: Replaces conflicting values with NAThe default is "both"
. This option has no effect for semiJoin and antiJoin.
suffix
: When keep == "both"
, specifies suffixes to use to disambiguate non-joined duplicate columns in a
and b
. May be:
a
and b
a
and b
, corresponding to suffixes for columns in a
and b
Suffixes are appended using an underscore as a separator. The default suffixes are "a"
and "b"
. This option has no effect for semiJoin and antiJoin.
by
is not null, there is a potential for non-joined duplicate columns between grids a
and b
. In the joined grid, some rows may have conflicting values in these columns, that is, values for the same key (column) that differ between a
and b
. The keep
option governs what happens when there is such a conflict. If instead either a
or b
is simply missing the duplicate key, then there is no conflict: the value from the other grid is included in the output.a
followed by any new columns from b
. Output row order depends on the type of join:
a
first followed by rows of b
b
first followed by rows of a
Consider two grids a
and b
:
a
:
name age hometown state ---- --- -------- ----- Bob 63 Chicago IL Jane 41 New York NY Nico 25 Portland ME
b
:
hometown state population -------- ----- ---------- New York NY 8,175,133 Denver CO 600,158 Portland OR 583,776 Portland ME 66,093
For these example grids, natural joins will use "hometown" and "state" as the by
columns.
innerJoin(a, b)
:
name age hometown state population ---- --- -------- ----- ---------- Jane 41 New York NY 8,175,133 Nico 25 Portland ME 66,093
leftJoin(a, b)
:
name age hometown state population ---- --- -------- ----- ---------- Bob 63 Chicago IL Jane 41 New York NY 8,175,133 Nico 25 Portland ME 66,093
rightJoin(a, b)
:
name age hometown state population ---- --- -------- ----- ---------- Jane 41 New York NY 8,175,133 Denver CO 600,158 Portland OR 583,776 Nico 25 Portland ME 66,093
fullJoin(a, b)
:
name age hometown state population ---- --- -------- ----- ---------- Bob 63 Chicago IL Jane 41 New York NY 8,175,133 Nico 25 Portland ME 66,093 Denver CO 600,158 Portland OR 583,776
semiJoin(a, b)
:
name age hometown state ---- --- -------- ----- Jane 41 New York NY Nico 25 Portland ME
antiJoin(a, b)
:
name age hometown state ---- --- -------- ----- Bob 63 Chicago IL
Things get more interesting if we omit "state" from the join columns.
innerJoin(a, b, "hometown")
:
name age hometown state_a state_b population ---- --- -------- ------- ------- ---------- Jane 41 New York NY NY 8,175,133 Nico 25 Portland ME OR 583,776 Nico 25 Portland ME ME 66,093
By default, keep == "both"
innerJoin(a, b, "hometown", {suffix:["person","place"]})
:
name age hometown state_person state_place population ---- --- -------- ------------ ----------- ---------- Jane 41 New York NY NY 8,175,133 Nico 25 Portland ME OR 583,776 Nico 25 Portland ME ME 66,093
innerJoin(a, b, "hometown", {keep:"a"})
:
name age hometown state population ---- --- -------- ----- ---------- Jane 41 New York NY 8,175,133 Nico 25 Portland ME 583,776 Nico 25 Portland ME 66,093
In practice, this particular case isn't very useful because the state-population match is now wrong.
A brief sampling of other useful functions:
is*
funtionsFor a complete list, see the function listing.
For a change log, see the Releases section of the nrelUtilityExt repository on GitHub.
Version | 1.1.4 |
---|---|
License | BSD-3-Clause-Clear |
Build date | 5 months ago on 3rd Dec 2021 |
File name | nrelUtilityExt.pod |
File size | 9.14 kB |
MD5 | 3c1afef8bfcd837d501b4e2dddd51df3 |
SHA1 | dfd59fdf25a789dabc912c9dc10addca332f1d9a |
Published by NRELDownload nowAlso available via SkyArc Install Manager |