# How to duplicate a dataset?

**URL:** <https://discuss.huggingface.co/t/how-to-duplicate-a-dataset/8558>\
**Category:** 🤗Datasets\
**Created:** [July 21, 2021, 4:35pm UTC](https://discuss.huggingface.co/t/how-to-duplicate-a-dataset/8558 "2021-07-21T16:35:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mralexis](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@mralexis](https://discuss.huggingface.co/u/mralexis)\
**Post date:** [July 21, 2021, 4:35pm UTC](https://discuss.huggingface.co/t/how-to-duplicate-a-dataset/8558/1 "2021-07-21T16:35:51Z")

</div>

Suppose I have a dataset `d` and I wanna have a copy of the whole dataset, something similar to `torch.clone()` for tensors and `copy.deepcopy` for regular python objects. Is there a way I could achieve this using `datasets`?

---

<div class="post-metadata">

**Author:** ![SMMousavi](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/smmousavi/32/2314_2.png) [@SMMousavi](https://discuss.huggingface.co/u/SMMousavi)\
**Post date:** [July 21, 2021, 6:03pm UTC](https://discuss.huggingface.co/t/how-to-duplicate-a-dataset/8558/2 "2021-07-21T18:03:27Z")

</div>

Why not using `copy.deepcopy` ?  
As answered in this question: [What is the diffrence between copy.deepcopy and flatten\_indices? - #2 by lhoestq](https://discuss.huggingface.co/t/what-is-the-diffrence-between-copy-deepcopy-and-flatten-indices/8484/2) , `copy.deepcopy` will create a copy of dataset.

It is just a few days that I’m using `transformers` and `datasets`, but up until now, everything I did with a `datasets` object, was without mutation, for example sorting, shuffling, selecting, filtering and using map does not change your `datasets` object, when there is no mutation, most of the times you don’t need to clone anything. So make sure if you really need to make a copy of `datasets` object.
