Hi, sort(countmap(df)) for a DataFrame df used to be something I was able to do but not anymore, so it seems that some package now throws an error. Is this intentional and if so, what is the new way to do this?
Thanks!
Hi, sort(countmap(df)) for a DataFrame df used to be something I was able to do but not anymore, so it seems that some package now throws an error. Is this intentional and if so, what is the new way to do this?
Thanks!
countmap needs an iterable of values and a DataFrame is not iterable (though the wrappers eachrow and eachcol are).
For frequency order, in my environment this simple example works: sort(countmap(df.colname); by=last, rev=true)
where the specific DataFrame column (df.colname) is an AbstractVector and works directly.
Sorry, that’s what I meant, df.colname.
sort(countmap(df.age);by=last,rev=true)
ERROR: MethodError: no method matching sort(::Dict{Int64, Int64}; by::typeof(last), rev::Bool)
The function `sort` exists, but no method is defined for this combination of argument types.
Closest candidates are:
sort(::BenchmarkTools.Trial) got unsupported keyword arguments "by", "rev"
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/ZtsPk/src/trials.jl:55
sort(::OrderedCollections.LittleSet{T, <:Tuple}; ks...) where T
@ OrderedCollections ~/.julia/packages/OrderedCollections/sd1va/src/little_set.jl:135
sort(::OrderedCollections.LittleSet{T, <:AbstractVector{T}}; ks...) where T
@ OrderedCollections ~/.julia/packages/OrderedCollections/sd1va/src/little_set.jl:138
...
Stacktrace:
[1] top-level scope
@ none:1
To fix this, convert the countmap output dictionary into an array of pairs using collect().
In my older test environment in Android phone, collect() was not required, but the issue seems to stem from the deprecated functionality sort(d::Dict; args...) in OrderedCollections v2.0.0.