JuliaData / JuliaData/DataFramesMeta.jl
Add convenience function to look up a single value in a `DataFrame`
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 496
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
It would work similarly to @rsubset but it would automatically call only and extract the desired value.
For example:
julia> df = DataFrame(x = 1:5, y = ["A","A","B","B","B"], z = (1:5)./10)
5×3 DataFrame
Row │ x y z
│ Int64 String Float64
─────┼────────────────────────
1 │ 1 A 0.1
2 │ 2 A 0.2
3 │ 3 B 0.3
4 │ 4 B 0.4
5 │ 5 B 0.5
julia> zvalue = @rsubset(df, :x > 1, :y == "A").z |> only
0.2
julia> zvalue = @lookup(df, :z, :x > 1, :y == "A")
0.2
It could maybe also work without the second argument to return a DataFrameRow.
It was mentioned that this may need to be called rlookup to match rsubset, but I think that is not necessary if the single value method is implemented. (This discussion started in the DataFrames.jl repository: https://github.com/JuliaData/DataFrames.jl/issues/3051#issuecomment-2059978408)
Would this function make DataFrames lookups more accessible to newcomers, or is the existing @rsubset functionality good enough?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the existing @rsubset functionality and the linked DataFrames.jl discussion first. Resolve whether the feature should be @lookup or rlookup, define behavior with and without the column argument, and confirm completion with tests covering the example lookup and DataFrameRow result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100