-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best (simple) way to get distinct values from a column ? #113
Comments
Like so? (v4+): dt.rollup({ values: op.array_agg_distinct(‘risk’) })
.get(‘values’, 0) That is the most efficient route... Also note that your examples are not equivalent. In particular, |
ok, thank you for the caveat regarding I think i will go on with which seems to me a bit easier to recall and teach |
The aq.addTableMethod('distinctArray', (table, columnName) => {
return table.rollup({ values: op.array_agg_distinct(columnName) }).get('values', 0);
});
// ...
dt.distinctArray('risk') // now returns array of distinct values |
Thank you for the hint, i should really use addTableMethod more often! Actually, as an happy Arquero user, it doesn't bother me too much to use a more verbose syntax or new methods like the one you suggest. But as a teacher, i really want non JS specialists (and R users) to be able to use Arquero in the most simple and intuitive way, this is why i am a bit of a pain on these topics :) |
I have a table
t1
with arisk
nominal columnand i want all distinct values in an array this is quite a common need i am having.
I really appreciate the new
columnArray()
Table method.I am actually hesitating between different paths, having difficulties to select and remind which would be the best:
Maybe i am missing here something simplier.
Wish i could use something very simple such as
t1.distinct('risk')
The text was updated successfully, but these errors were encountered: