# How to slice an already loaded Dataset?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-slice-an-already-loaded-dataset%2F27946%3E%5C
**Category:** 🤗Datasets\
**Created:** [December 16, 2022, 2:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-slice-an-already-loaded-dataset%2F27946 "2022-12-16T14:01:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredguth](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fredguth/32/2843_2.png) [@fredguth](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffredguth)%5C
**Post date:** [December 16, 2022, 2:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-slice-an-already-loaded-dataset%2F27946%2F1 "2022-12-16T14:01:30Z")

</div>

Using Datasets version ‘2.6.1’, how do I slice a take a Dataset object and slice it (for example only the first 100 examples) and get a Dataset?

`dd = load_dataset` is a `DatasetDict`.  
`dd['train']` is a `Dataset`.

If I `dd['train'][:100]`, I get a `dict` not a Dataset object anymore. Also I can’t create a new Dataset with `datasets.Dataset(dd['train'][:100])`.

I have seen some examples in the forum of a method called `take`.

But `Dataset.take` does not seem to exist anymore.

I guess this is for an old version of Dataset, how to slice an already loaded Dataset?

---

<div class="post-metadata">

**Author:** ![fredguth](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fredguth/32/2843_2.png) [@fredguth](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffredguth)%5C
**Post date:** [December 16, 2022, 2:36pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-slice-an-already-loaded-dataset%2F27946%2F2 "2022-12-16T14:36:38Z")

</div>

Got it. The method now is `select`

---

<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:** [December 16, 2022, 3:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-slice-an-already-loaded-dataset%2F27946%2F3 "2022-12-16T15:33:17Z")

</div>

Yes, `select` is the correct answer.

Btw, `Dataset.take` was never a part of the API, but we may add it eventually to be consistent with the `IterableDataset`, which is returned in the streaming mode.
