# Reverse instances in a Dataset

**URL:** <https://discuss.huggingface.co/t/reverse-instances-in-a-dataset/8810>\
**Category:** 🤗Datasets\
**Created:** [July 29, 2021, 4:37pm UTC](https://discuss.huggingface.co/t/reverse-instances-in-a-dataset/8810 "2021-07-29T16:37:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aktsvigun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aktsvigun/32/19418_2.png) [@Aktsvigun](https://discuss.huggingface.co/u/Aktsvigun)\
**Post date:** [July 29, 2021, 4:37pm UTC](https://discuss.huggingface.co/t/reverse-instances-in-a-dataset/8810/1 "2021-07-29T16:37:48Z")

</div>

Hi,  
I need to make a `train_test_split` of the dataset (namely, of its `train` part). I want to split it in such a way so that the instances _are not shuffled_, but _test_ part is consisted of **first** `test_size` elements (instead of **last** `test_size` elements, as it is done by default when doing `dataset.train_test_split(test_size=test_size, shuffle=False)`).

There is certainly a primitive way of doing it with  
`test_data = dataset.train_test_split(train_size=test_size, shuffle=False)['train']`  
but since I am writing a public code, it will cause misunderstanding.

To sum up, is there a way of doing it “more beautiful”?  
Thanks!

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](https://discuss.huggingface.co/u/lhoestq)\
**Post date:** [August 23, 2021, 4:14pm UTC](https://discuss.huggingface.co/t/reverse-instances-in-a-dataset/8810/2 "2021-08-23T16:14:23Z")

</div>

Hi ! Indeed it’s not convenient to see that this is in reverse order compared to scikit-learn

Currently there isn’t a more satisfactory solution, but feel free to to open an issue on github to discuss this behavior and how we can improve it
