Better methods for showing metadata
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start by reviewing the existing colmetadata API and how names(df) exposes table columns. Compare the proposed showcolmetadata overloads and their example output, then check the current tests or documentation for metadata display; done means the requested column and label combinations are supported with readable tabular output.
Written by the indexing model from the issue text.
Description
I'm using metadata for the first time today (I usually use Stata and R for data cleaning) and I found it helpful to define the following functions to make it easier to see metadata
function showcolmetadata(df, col::Union{AbstractString, Symbol}, label::AbstractString)
colmetadata(df, col, label)
end
function showcolmetadata(df, cols::AbstractVector{<:Union{AbstractString, Symbol}}, label::AbstractString)
labvals = [colmetadata(df, col, label) for col in cols]
nt = (; :variable => cols, Symbol(label) => labvals)
pretty_table(nt; nosubheader = true, crop = :horizontal, alignment = [:l, :l])
end
function showcolmetadata(df, col::Union{AbstractString, Symbol}, labels::AbstractVector{<:AbstractString})
labvals = [colmetadata(df, col, label) for label in labels]
nt(; :label => labels, :value => labvals)
pretty_table(nt; nosubheader = true, tile = "colmetadata for $col", crop = :horizontal, alignment = [:l, :l])
end
function showcolmetadata(df, cols::Colon, label::AbstractString)
showcolmetadata(df, names(df), label)
end
function showcolmetadata(df, col::Union{AbstractString, Symbol}, labels::Colon)
d = colmetadata(df, col)
labnames = names(d)
showcolmetadata(df, col, labnames)
end
They would be used like following: You can see that the column names are pretty uninformative in the Penn World Tables, exactly the kind of situation metadata is great for.
julia> showcolmetadata(pwt[:, 1:10], :, "label")
┌───────────────┬──────────────────────────────────────────────────────────
│ variable │ label ⋯
├───────────────┼──────────────────────────────────────────────────────────
│ countrycode │ 3-letter ISO country code ⋯
│ country │ Country name ⋯
│ currency_unit │ Currency unit ⋯
│ year │ Year ⋯
│ rgdpe │ Expenditure-side real GDP at chained PPPs (in mil. 2017 ⋯
│ rgdpo │ Output-side real GDP at chained PPPs (in mil. 2017US$) ⋯
│ pop │ Population (in millions) ⋯
│ emp │ Number of persons engaged (in millions) ⋯
│ avh │ Average annual hours worked by persons engaged (source: ⋯
│ hc │ Human capital index, see note hc ⋯
└───────────────┴──────────────────────────────────────────────────────────
1 column omitted
- Dominant language
- Julia
- Stars
- 19
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from JuliaData/TableMetadataTools.jl
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
JuliaData/TableMetadataTools.jl#4 · 1 reaction ·
All issues in JuliaData/TableMetadataTools.jl
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
JuliaStats/LogExpFunctions.jl#134 · 2 comments ·
-
code bug PowerSystems 6.0
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Sienna-Platform/PowerSystems.jl#1849 ·
Maintainers usually reply within 7 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FluxML/Metalhead.jl#407 ·
Maintainers usually reply within 1 day