# How to add metadata info to a DataFrame?

**URL:** https://discourse.julialang.org/t/how-to-add-metadata-info-to-a-dataframe/11168
**Category:** Data
**Tags:** dataframes, metadata
**Created:** [May 26, 2018, 3:21pm UTC](https://discourse.julialang.org/t/how-to-add-metadata-info-to-a-dataframe/11168 "2018-05-26T15:21:35Z")
**Posts on this page:** 1
**Showing post:** 95

<div class="post-metadata">

### Author: ![gcalderone](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gcalderone/32/1539_2.png) [@gcalderone](https://discourse.julialang.org/u/gcalderone)
#### Post date: [January 14, 2019, 4:39pm UTC](https://discourse.julialang.org/t/how-to-add-metadata-info-to-a-dataframe/11168/95 "2019-01-14T16:39:22Z")

</div>

Dear all,  
this topic has been inactive for a few months, but I just wanted to add that I implemented a package to solve the first problem posted, namely how to add metadata information to a DataFrame.

The trick is to use [composition](https://en.wikipedia.org/wiki/Object_composition) and the [ReusePatterns](https://github.com/gcalderone/ReusePatterns.jl) package to automatically forward all method calls from one type to another. The relevant code is:

```julia
using ReusePatterns
struct DataFrameMeta <: AbstractDataFrame
    p::DataFrame
    meta::Dict{String, Any}
    DataFrameMeta(args...; kw...) = new(DataFrame(args...; kw...), Dict{Symbol, Any}())
    DataFrameMeta(df::DataFrame) = new(df, Dict{Symbol, Any}())
end
meta(d::DataFrameMeta) = getfield(d,:meta) # <-- new functionality added to DataFrameMeta
@forward((DataFrameMeta, :p), DataFrame) # <-- reuse all existing functionalities

```

while the whole example can be found [here](https://github.com/gcalderone/ReusePatterns.jl/blob/master/examples/dataframes.jl).

With the above code we can use an object of type `DataFrameMeta` as if it was a simple `DataFrame`, but taking advantage of the new `meta` method to gain access to the associated metadata dictionary.

Comments are welcome!

---

_[View the full topic](https://discourse.julialang.org/t/how-to-add-metadata-info-to-a-dataframe/11168)._
