Skip to content

Commit a45c104

Browse files
authored
Improve metadata documentation (#3169)
1 parent f17f2c7 commit a45c104

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/src/lib/metadata.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ Table-level metadata are key-value pairs that are attached to `df`.
1717
Column-level metadata are key-value pairs that are attached to
1818
a specific column `col` of `df` data frame.
1919

20+
To check whether some key `key` is present in table-level metadata of data frame `df`
21+
you can write `key in metadatakeys(df)`. Similarly to check whether key `key` is present
22+
in column-level metadata of data frame `df` for column `col` write
23+
`key in colmetadatakeys(df, col)`.
24+
2025
Additionally each metadata key-value pair has a style information attached to
2126
it.
2227
In DataFrames.jl the metadata style influences how metadata is propagated when
@@ -53,9 +58,9 @@ functions. In this section collectively these objects will be called
5358
* [`SubDataFrame`](@ref) and [`DataFrameRow`](@ref) only expose metadata from
5459
their parent `DataFrame` whose style is `:note`.
5560

56-
Notably metadata is not supported for [`GroupedDataFrame`](@ref) as it does not
57-
expose columns directly. You can inspect metadata of the `parent` of a
58-
[`GroupedDataFrame`](@ref) or of any of its groups.
61+
Notably, metadata is not supported for [`GroupedDataFrame`](@ref) and you can't
62+
add, modify, nor view metadata through the [`GroupedDataFrame`](@ref) itself.
63+
It is possible only through its `parent`.
5964

6065
!!! note
6166

@@ -121,6 +126,9 @@ julia> collect(metadatakeys(df))
121126
1-element Vector{String}:
122127
"caption"
123128
129+
julia> "caption" in metadatakeys(df)
130+
true
131+
124132
julia> metadata(df, "caption")
125133
"ELO ratings of chess players"
126134
@@ -141,6 +149,9 @@ julia> colmetadata!(df, :date, "label", "Rating date in yyyy-u format", style=:n
141149
142150
julia> colmetadata!(df, :rating, "label", "ELO rating in classical time control", style=:note);
143151
152+
julia> "label" in colmetadatakeys(df, :rating)
153+
true
154+
144155
julia> colmetadata(df, :rating, "label")
145156
"ELO rating in classical time control"
146157

0 commit comments

Comments
 (0)