Expr.adoc/groupby: group keys are strings
This commit is contained in:
+5
-3
@@ -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.
|
||||
|
||||
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
|
||||
`>>>` [blue]`[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}, {"name": "Charlie", "age": 30}] groupby "age"` +
|
||||
[source,json]
|
||||
[source,yaml]
|
||||
----
|
||||
{
|
||||
25: [
|
||||
"25": [
|
||||
{
|
||||
"name": "Bob",
|
||||
"age": 25
|
||||
}
|
||||
],
|
||||
30: [
|
||||
"30": [
|
||||
{
|
||||
"name": "Alice",
|
||||
"age": 30
|
||||
|
||||
Reference in New Issue
Block a user