# Adding Metadata to a dataset

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadding-metadata-to-a-dataset%2F165626%3E%5C
**Category:** Beginners\
**Created:** [August 4, 2025, 5:21pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadding-metadata-to-a-dataset%2F165626 "2025-08-04T17:21:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielruss](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@danielruss](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdanielruss)%5C
**Post date:** [August 4, 2025, 5:21pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadding-metadata-to-a-dataset%2F165626%2F1 "2025-08-04T17:21:08Z")

</div>

Hi, I have a dataset where the text has a label that is a standardized code. The each code has a title describing the code. The data is in a pandas df called jobs\_data

```auto
data = {
    "text": jobs_data.JobTitle.to_list(),
    "label": jobs_data.soc2010.to_list(),
}
features = {
    "text": Value("string"),
    "label": ClassLabel(names=soc2010.code.to_list()),
}

jobs_ds = Dataset.from_dict(data,features=Features(features))

```

I would like to include a codes to title dictionary/function to make it easier to convert from a label → code → title  
Is this possible?  
Thank you

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [August 5, 2025, 12:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadding-metadata-to-a-dataset%2F165626%2F2 "2025-08-05T00:28:09Z")

</div>

If metadata alone is sufficient, using [the `DatasetInfo` class](https://huggingface.co/docs/datasets/v4.0.0/en/package_reference/main_classes#datasets.DatasetInfo) is probably the quickest option.

```py
from datasets import DatasetInfo

data = {
    "text": jobs_data.JobTitle.to_list(),
    "label": jobs_data.soc2010.to_list(),
}

features = {
    "text": Value("string"),
    "label": ClassLabel(names=soc2010.code.to_list()),
}

code2title = "codes to convert from a label → code → title"

info = DatasetInfo(
    description="Jobs dataset with SOC‐2010 codes",
    metadata={"code2title": code2title}
)

jobs_ds = Dataset.from_dict(data, features=Features(features), info=info)

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [September 4, 2025, 8:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadding-metadata-to-a-dataset%2F165626%2F3 "2025-09-04T20:41:28Z")

</div>

Closed on September 4, 2025, 8:41pm UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
