Answer: Sorting a counter (and extracting the most common values)
Pan Chasinga
Posted on September 5, 2019
To update this question, I'm using Julia v1.2.1 and there is no select!
afaik.
Here is a slight modification to @Toivo's implementation I used:
using DataStructures
most_common(c::Accumulator) = most_common(c, length(c))
most_common(c::Accumulator, k) = sort(collect(c), by=kv->kv[2], rev=true)[1:k]
This returns an ::Array{Pair{String,Int}},1
with k
members which is similar to Python Counter.most_common(k)
which…
💖 💪 🙅 🚩
Pan Chasinga
Posted on September 5, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024