# How to duplicate a dataset?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-duplicate-a-dataset%2F8558%3E%5C
**Category:** 🤗Datasets\
**Created:** [July 21, 2021, 4:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-duplicate-a-dataset%2F8558 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmralexis)%5C
**Post date:** [July 21, 2021, 4:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-duplicate-a-dataset%2F8558%2F1 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSMMousavi)%5C
**Post date:** [July 21, 2021, 6:03pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-duplicate-a-dataset%2F8558%2F2 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwhat-is-the-diffrence-between-copy-deepcopy-and-flatten-indices%2F8484%2F2) , `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.
