FLATTEN¶
Description¶
FLATTEN takes a list of dictionaries and extracts values from them. 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 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"].