Closed mrmanicou closed 4 years ago
Hi. I'm not sure I understand what you mean. Could you give an example of how you'd want to use groupBy?
@tomi - I am also interested in doing this. Here is an example of what I am trying to do. This uses the example data at https://tomi.github.io/fromfrom/playground.html
import { from } from "fromfrom";
import data from "data";
from(data)
.groupBy(d => ({"c": d.country, "g": d.gender}))
.map(d => ({"c": d.key.c, "g": d.key.g, "count": d.items.length}))
.toArray()
Basically I want the number of elements in the sequence for every country
and gender
combination. But it looks like groupBy
cannot compare objects to actually group them so the resulting array ends up flat and looks like this:
[
{
"c": "SE",
"g": "Male",
"count": 1
},
{
"c": "SE",
"g": "Male",
"count": 1
}
]
Is there a way to accomplish this? Thanks in advance for your help and for your great work on this incredible project!
Hi @9ee1 and thank you for clarifying the use case! I implemented this in #91 and it should be available in the next release.
Awesome! Thank you very much @tomi.
Doesn't seem to work when I do this