FLATTEN¶
Description¶
FLATTEN extracts values from a list.
Given a list of dictionaries and a key (or a tuple of keys), it returns a flat list of the values at that key across all
dictionaries.
If called with no second argument, it concatenates the elements of the list (e.g. sublists or strings) into a single value.
Example with a single key¶
This extracts the value at "key" from each dictionary, returning ["a", "b"].
Example with multiple keys¶
FLATTEN([{"key": "a", "age": 25, "name": "Alice"}, {"key": "b", "age": 30, "name": "Bob"}], ("key", "name"))
This returns only the specified keys from each dictionary:
[{"key":
"a", "name":
"Alice"}, {"key":
"b", "name":
"Bob"}].
Example without a key¶
This concatenates the sublists into a single list, returning ["a", "b", "c", "d"].