Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Better methods for showing metadata

未关闭
#3 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
julia
领域
data

调研方向

首先检查现有的 colmetadata API,以及 names(df) 如何公开表列。比较提议的 showcolmetadata 重载及其示例输出,然后检查当前关于元数据显示的测试或文档;当所请求的列和标签组合能够以可读的表格输出形式得到支持时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Julia
星标
19
派生
1
平均合并
8 分钟
30 天内合并 PR
3

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaData/TableMetadataTools.jl 的其他 Issue

查看 JuliaData/TableMetadataTools.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。