Expr.adoc/groupby: group keys are strings

This commit is contained in:
2026-06-03 09:11:51 +02:00
parent b86ce6fe62
commit 73e4ad7b87
+5 -3
View File
@@ -1920,18 +1920,20 @@ Syntax: +
The left side of [blue]`groupby` operator is a list ofdictionaries or an iterator over a list of dictionaries. It takes a key and returns a dictionary where the keys are the unique values of the specified key in the dictionaries and the values are lists of dictionaries that have that key value. In other words, it groups the dictionaries by the specified key value. The left side of [blue]`groupby` operator is a list ofdictionaries or an iterator over a list of dictionaries. It takes a key and returns a dictionary where the keys are the unique values of the specified key in the dictionaries and the values are lists of dictionaries that have that key value. In other words, it groups the dictionaries by the specified key value.
NOTE: Currently, keys of group are always strings. In the future, it will be possible to specify a key function to compute the keys of the groups.
.Examples .Examples
`>>>` [blue]`[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}, {"name": "Charlie", "age": 30}] groupby "age"` + `>>>` [blue]`[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}, {"name": "Charlie", "age": 30}] groupby "age"` +
[source,json] [source,yaml]
---- ----
{ {
25: [ "25": [
{ {
"name": "Bob", "name": "Bob",
"age": 25 "age": 25
} }
], ],
30: [ "30": [
{ {
"name": "Alice", "name": "Alice",
"age": 30 "age": 30