Reputation: 6731
I am not new to programming but I am new to Julia. I have a Julia dictionary object that looks like the following:
Dict{Any,Any}(28.1=>1, 132.0=>2, 110.0=>3)
How can I write code to filter out the values that meet a certain criteria? Like let's say that I want all pairs where the value is >2 or >=2. I'm basically looking for the LINQ equivalent in Julia.
Upvotes: 9
Views: 2148
Reputation: 12051
In Base
, the standard way is to use map
and filter
:
julia> d = Dict{Any,Any}(28.1=>1, 132.0=>2, 110.0=>3);
julia> filter((k, v) -> v > 2, d)
Dict{Any,Any} with 1 entry:
110.0 => 3
If you use DataFrames, there is a LINQ-like interface in DataFramesMeta.
Upvotes: 9