Array Utils
Array Transformations
mismo.arrays.array_shuffle(a: ir.ArrayValue) -> ir.ArrayValue
Shuffle an array.
mismo.arrays.array_choice(a: ir.ArrayValue, n: int) -> ir.ArrayValue
Randomly select n
elements from an array.
mismo.arrays.array_combinations(left: ir.ArrayValue, right: ir.ArrayValue) -> ir.ArrayValue
Generate all combinations of elements from two arrays.
This is the cartesian product of the two arrays.
PARAMETER | DESCRIPTION |
---|---|
left |
The first array.
TYPE:
|
right |
The second array.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
combinations
|
An |
mismo.arrays.array_filter_isin_other(t: ir.Table, array: ir.ArrayColumn | str, other: ir.Column, *, result_format: str = '{name}_filtered') -> ir.Table
Equivalent to t.mutate(result_name=t[array].filter(lambda x: x.isin(other)))
We can't have subqueries in the filter lambda (need this to avoid https://stackoverflow.com/questions/77559936/how-to-implementlist-filterarray-elem-elem-in-column-in-other-table))
See issues/32 for more info.
PARAMETER | DESCRIPTION |
---|---|
t |
The table containing the array column.
TYPE:
|
array |
A reference to the array column.
TYPE:
|
other |
The column to filter against.
TYPE:
|
result_format |
The format string to use for the result column name. The format string
should have a single placeholder,
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Table
|
The table with a new column named following |
Array Aggregations
mismo.arrays.array_any(array) -> bool
Return True if any elements in the array are True, False otherwise.
NULL values are ignored. If there are no non-NULL values, returns NULL.
mismo.arrays.array_all(array) -> bool
Return True if all elements in the array are True, False otherwise.
NULL values are ignored. If there are no non-NULL values, returns NULL.
mismo.arrays.array_min(array: ir.ArrayValue) -> ir.NumericValue
Get the minimum value of an array.
mismo.arrays.array_max(array: ir.ArrayValue) -> ir.NumericValue
Get the maximum value of an array.
mismo.arrays.array_mean(array: ir.ArrayValue) -> ir.FloatingValue
Get the mean value of an array.
mismo.arrays.array_median(array: ir.ArrayValue) -> ir.FloatingValue
Get the median value of an array.
mismo.arrays.array_sum(array: ir.ArrayValue) -> ir.NumericValue
Get the sum of all values of an array.