# Efficient way to concatenate DatasetDict objects

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fefficient-way-to-concatenate-datasetdict-objects%2F42395%3E%5C
**Category:** 🤗Datasets\
**Created:** [June 7, 2023, 11:13am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fefficient-way-to-concatenate-datasetdict-objects%2F42395 "2023-06-07T11:13:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhavitvyamalik](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bhavitvyamalik/32/30215_2.png) [@bhavitvyamalik](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbhavitvyamalik)%5C
**Post date:** [June 7, 2023, 11:13am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fefficient-way-to-concatenate-datasetdict-objects%2F42395%2F1 "2023-06-07T11:13:51Z")

</div>

Is there any efficient way to combine DatasetDict objects? Current concatenate method works for Dataset object only. Thanks!

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmariosasko)%5C
**Post date:** [June 12, 2023, 7:54pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fefficient-way-to-concatenate-datasetdict-objects%2F42395%2F2 "2023-06-12T19:54:10Z")

</div>

No, but if all of them have the same set of keys, this should work:

```python
dd = DatasetDict()
for key in dd_to_concat:
    dd[key] = datasets.concatenate_datasets([ddd[key] for ddd in dd_to_concat])

```

PS: our goal is to remove the DatasetDict API eventually, as explained in [Reduce friction in tabular dataset workflow by eliminating having splits when dataset is loaded · Issue #5189 · huggingface/datasets · GitHub](https://github.com/huggingface/datasets/issues/5189), so it’s unlikely that we will add support for `DatasetDict` objects in `concatenate_datasets`.
