Array Utils
Array Transformations
mismo.arrays.array_shuffle
array_shuffle(a: ArrayValue) -> ArrayValue
Shuffle an array.
mismo.arrays.array_choice
array_choice(a: ArrayValue, n: int) -> ArrayValue
Randomly select n
elements from an array.
mismo.arrays.array_combinations
array_combinations(
left: ArrayValue, right: ArrayValue
) -> 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
array_filter_isin_other(
t: Table,
array: ArrayColumn | str,
other: Column,
*,
result_format: str = "{name}_filtered",
) -> 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_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_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_min(array: ArrayValue) -> NumericValue
Get the minimum value of an array.
mismo.arrays.array_max
array_max(array: ArrayValue) -> NumericValue
Get the maximum value of an array.
mismo.arrays.array_mean
array_mean(array: ArrayValue) -> FloatingValue
Get the mean value of an array.
mismo.arrays.array_median
array_median(array: ArrayValue) -> FloatingValue
Get the median value of an array.
mismo.arrays.array_sum
array_sum(array: ArrayValue) -> NumericValue
Get the sum of all values of an array.