import{S as Zl,i as en,s as tn,e as n,k as c,w as m,t as s,M as an,c as r,d as a,m as d,a as o,x as u,h as l,b as h,G as t,g as p,y as g,L as sn,q as v,o as b,B as w,v as ln}from"../chunks/vendor-hf-doc-builder.js";import{I as Me}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as q}from"../chunks/CodeBlock-hf-doc-builder.js";function nn(Vs){let S,ut,T,L,Ke,Z,oa,Ue,ia,gt,x,pa,ge,ha,ca,ve,da,fa,be,ma,ua,we,ga,va,vt,k,ba,xe,wa,xa,_e,_a,ya,bt,F,z,We,ee,ja,Qe,$a,wt,E,ka,ye,Ea,Da,je,Ia,Aa,xt,O,Pa,te,qa,Sa,_t,ae,yt,B,H,Ve,se,Ta,Xe,Fa,jt,D,Ba,$e,Na,Ca,Ze,Ja,Ga,$t,le,kt,Y,La,et,za,Oa,Et,ne,Dt,ke,Ha,It,re,At,Ee,Ya,Pt,oe,qt,De,Ra,St,ie,Tt,N,R,tt,pe,Ma,at,Ka,Ft,M,Ua,st,Wa,Qa,Bt,he,Nt,C,K,lt,ce,Va,nt,Xa,Ct,_,Za,Ie,es,ts,rt,as,ss,ot,ls,ns,Ae,rs,os,Jt,de,Gt,U,is,Pe,ps,hs,Lt,f,cs,qe,ds,fs,Se,ms,us,Te,gs,vs,it,bs,ws,pt,xs,_s,Fe,ys,js,zt,fe,Ot,W,$s,Be,ks,Es,Ht,me,Yt,$,Ds,Ne,Is,As,Ce,Ps,qs,Je,Ss,Ts,Rt,J,Q,ht,ue,Fs,ct,Bs,Mt,V,Ns,G,Cs,dt,Js,Gs,ft,Ls,zs,Kt,y,Os,Ge,Hs,Ys,Le,Rs,Ms,ze,Ks,Us,Oe,Ws,Qs,Ut;return Z=new Me({}),ee=new Me({}),ae=new q({props:{code:`from datasets import load_dataset

dataset = load_dataset("rotten_tomatoes", split="train")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;rotten_tomatoes&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`}}),se=new Me({}),le=new q({props:{code:"dataset[0]",highlighted:`<span class="hljs-comment"># Get the first row in the dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;the rock is destined to be the 21st century\\&#x27;s new &quot; conan &quot; and that he\\&#x27;s going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .&#x27;</span>}`}}),ne=new q({props:{code:"dataset[-1]",highlighted:`<span class="hljs-comment"># Get the last row in the dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[-<span class="hljs-number">1</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;things really get weird , though not particularly scary : the movie is all portent and no content .&#x27;</span>}`}}),re=new q({props:{code:'dataset["text"]',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-string">&quot;text&quot;</span>]
[<span class="hljs-string">&#x27;the rock is destined to be the 21st century\\&#x27;s new &quot; conan &quot; and that he\\&#x27;s going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .&#x27;</span>,
 <span class="hljs-string">&#x27;the gorgeously elaborate continuation of &quot; the lord of the rings &quot; trilogy is so huge that a column of words cannot adequately describe co-writer/director peter jackson\\&#x27;s expanded vision of j . r . r . tolkien\\&#x27;s middle-earth .&#x27;</span>,
 <span class="hljs-string">&#x27;effective but too-tepid biopic&#x27;</span>,
 ...,
 <span class="hljs-string">&#x27;things really get weird , though not particularly scary : the movie is all portent and no content .&#x27;</span>]`}}),oe=new q({props:{code:'dataset[0]["text"]',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;text&quot;</span>]
<span class="hljs-string">&#x27;the rock is destined to be the 21st century\\&#x27;s new &quot; conan &quot; and that he\\&#x27;s going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .&#x27;</span>`}}),ie=new q({props:{code:`with Timer():
   dataset[0]['text']

with Timer():
  dataset["text"][0]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> Timer():
<span class="hljs-meta">... </span>   dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&#x27;text&#x27;</span>]
Elapsed time: <span class="hljs-number">0.0031</span> seconds

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> Timer():
<span class="hljs-meta">... </span>  dataset[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>]
Elapsed time: <span class="hljs-number">0.0094</span> seconds`}}),pe=new Me({}),he=new q({props:{code:`dataset[:3]

dataset[3:6]`,highlighted:`<span class="hljs-comment"># Get the first three rows</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[:<span class="hljs-number">3</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
 <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;the rock is destined to be the 21st century\\&#x27;s new &quot; conan &quot; and that he\\&#x27;s going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .&#x27;</span>,
  <span class="hljs-string">&#x27;the gorgeously elaborate continuation of &quot; the lord of the rings &quot; trilogy is so huge that a column of words cannot adequately describe co-writer/director peter jackson\\&#x27;s expanded vision of j . r . r . tolkien\\&#x27;s middle-earth .&#x27;</span>,
  <span class="hljs-string">&#x27;effective but too-tepid biopic&#x27;</span>]}

<span class="hljs-comment"># Get rows between three and six</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">3</span>:<span class="hljs-number">6</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
 <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;if you sometimes like to go to the movies to have fun , wasabi is a good place to start .&#x27;</span>,
  <span class="hljs-string">&quot;emerges as something rare , an issue movie that&#x27;s so honest and keenly observed that it doesn&#x27;t feel like one .&quot;</span>,
  <span class="hljs-string">&#x27;the film provides some great insight into the neurotic mindset of all comics -- even those who have reached the absolute top of the game .&#x27;</span>]}`}}),ce=new Me({}),de=new q({props:{code:`from datasets import load_dataset

iterable_dataset = load_dataset("food101", split="train", streaming=True)
for example in iterable_dataset:
    print(example)
    break`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>iterable_dataset = load_dataset(<span class="hljs-string">&quot;food101&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> iterable_dataset:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(example)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">break</span>
{<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=384x512 at <span class="hljs-number">0x7F0681F5C520</span>&gt;, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">6</span>}`}}),fe=new q({props:{code:`next(iter(iterable_dataset))

for example in iterable_dataset:
    print(example)
    break`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(iterable_dataset))
{<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=384x512 at <span class="hljs-number">0x7F0681F59B50</span>&gt;,
 <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">6</span>}

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> iterable_dataset:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(example)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">break</span>
{<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=384x512 at <span class="hljs-number">0x7F7479DE82B0</span>&gt;, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">6</span>}`}}),me=new q({props:{code:"list(iterable_dataset.take(3))",highlighted:`<span class="hljs-comment"># Get first three examples</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(iterable_dataset.take(<span class="hljs-number">3</span>))
[{<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=384x512 at <span class="hljs-number">0x7F7479DEE9D0</span>&gt;,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">6</span>},
 {<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=512x512 at <span class="hljs-number">0x7F7479DE8190</span>&gt;,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">6</span>},
 {<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=512x383 at <span class="hljs-number">0x7F7479DE8310</span>&gt;,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">6</span>}]`}}),ue=new Me({}),{c(){S=n("meta"),ut=c(),T=n("h1"),L=n("a"),Ke=n("span"),m(Z.$$.fragment),oa=c(),Ue=n("span"),ia=s("Know your dataset"),gt=c(),x=n("p"),pa=s("There are two types of dataset objects, a regular "),ge=n("a"),ha=s("Dataset"),ca=s(" and then an \u2728 "),ve=n("a"),da=s("IterableDataset"),fa=s(" \u2728. A "),be=n("a"),ma=s("Dataset"),ua=s(" provides fast random access to the rows, and memory-mapping so that loading even large datasets only uses a relatively small amount of device memory. But for really, really big datasets that won\u2019t even fit on disk or in memory, an "),we=n("a"),ga=s("IterableDataset"),va=s(" allows you to access and use the dataset without waiting for it to download completely!"),vt=c(),k=n("p"),ba=s("This tutorial will show you how to load and access a "),xe=n("a"),wa=s("Dataset"),xa=s(" and an "),_e=n("a"),_a=s("IterableDataset"),ya=s("."),bt=c(),F=n("h2"),z=n("a"),We=n("span"),m(ee.$$.fragment),ja=c(),Qe=n("span"),$a=s("Dataset"),wt=c(),E=n("p"),ka=s("When you load a dataset split, you\u2019ll get a "),ye=n("a"),Ea=s("Dataset"),Da=s(" object. You can do many things with a "),je=n("a"),Ia=s("Dataset"),Aa=s(" object, which is why it\u2019s important to learn how to manipulate and interact with the data stored inside."),xt=c(),O=n("p"),Pa=s("This tutorial uses the "),te=n("a"),qa=s("rotten_tomatoes"),Sa=s(" dataset, but feel free to load any dataset you\u2019d like and follow along!"),_t=c(),m(ae.$$.fragment),yt=c(),B=n("h3"),H=n("a"),Ve=n("span"),m(se.$$.fragment),Ta=c(),Xe=n("span"),Fa=s("Indexing"),jt=c(),D=n("p"),Ba=s("A "),$e=n("a"),Na=s("Dataset"),Ca=s(" contains columns of data, and each column can be a different type of data. The "),Ze=n("em"),Ja=s("index"),Ga=s(", or axis label, is used to access examples from the dataset. For example, indexing by the row returns a dictionary of an example from the dataset:"),$t=c(),m(le.$$.fragment),kt=c(),Y=n("p"),La=s("Use the "),et=n("code"),za=s("-"),Oa=s(" operator to start from the end of the dataset:"),Et=c(),m(ne.$$.fragment),Dt=c(),ke=n("p"),Ha=s("Indexing by the column name returns a list of all the values in the column:"),It=c(),m(re.$$.fragment),At=c(),Ee=n("p"),Ya=s("You can combine row and column name indexing to return a specific value at a position:"),Pt=c(),m(oe.$$.fragment),qt=c(),De=n("p"),Ra=s("But it is important to remember that indexing order matters, especially when working with large audio and image datasets. Indexing by the column name returns all the values in the column first, then loads the value at that position. For large datasets, it may be slower to index by the column name first."),St=c(),m(ie.$$.fragment),Tt=c(),N=n("h3"),R=n("a"),tt=n("span"),m(pe.$$.fragment),Ma=c(),at=n("span"),Ka=s("Slicing"),Ft=c(),M=n("p"),Ua=s("Slicing returns a slice - or subset - of the dataset, which is useful for viewing several rows at once. To slice a dataset, use the "),st=n("code"),Wa=s(":"),Qa=s(" operator to specify a range of positions."),Bt=c(),m(he.$$.fragment),Nt=c(),C=n("h2"),K=n("a"),lt=n("span"),m(ce.$$.fragment),Va=c(),nt=n("span"),Xa=s("IterableDataset"),Ct=c(),_=n("p"),Za=s("An "),Ie=n("a"),es=s("IterableDataset"),ts=s(" is loaded when you set the "),rt=n("code"),as=s("streaming"),ss=s(" parameter to "),ot=n("code"),ls=s("True"),ns=s(" in "),Ae=n("a"),rs=s("load_dataset()"),os=s(":"),Jt=c(),m(de.$$.fragment),Gt=c(),U=n("p"),is=s("An "),Pe=n("a"),ps=s("IterableDataset"),hs=s(" progressively iterates over a dataset one example at a time, so you don\u2019t have to wait for the whole dataset to download before you can use it. As you can imagine, this is quite useful for large datasets you want to use immediately!"),Lt=c(),f=n("p"),cs=s("However, this means an "),qe=n("a"),ds=s("IterableDataset"),fs=s("\u2019s behavior is different from a regular "),Se=n("a"),ms=s("Dataset"),us=s(". You don\u2019t get random access to examples in an "),Te=n("a"),gs=s("IterableDataset"),vs=s(". Instead, you should iterate over its elements, for example, by calling "),it=n("code"),bs=s("next(iter())"),ws=s(" or with a "),pt=n("code"),xs=s("for"),_s=s(" loop to return the next item from the "),Fe=n("a"),ys=s("IterableDataset"),js=s(":"),zt=c(),m(fe.$$.fragment),Ot=c(),W=n("p"),$s=s("You can return a subset of the dataset with a specific number of examples in it with "),Be=n("a"),ks=s("IterableDataset.take()"),Es=s(":"),Ht=c(),m(me.$$.fragment),Yt=c(),$=n("p"),Ds=s("But unlike "),Ne=n("a"),Is=s("slicing"),As=s(", "),Ce=n("a"),Ps=s("IterableDataset.take()"),qs=s(" creates a new "),Je=n("a"),Ss=s("IterableDataset"),Ts=s("."),Rt=c(),J=n("h2"),Q=n("a"),ht=n("span"),m(ue.$$.fragment),Fs=c(),ct=n("span"),Bs=s("Next steps"),Mt=c(),V=n("p"),Ns=s("Interested in learning more about the differences between these two types of datasets? Learn more about them in the "),G=n("a"),Cs=s("Differences between "),dt=n("code"),Js=s("Dataset"),Gs=s(" and "),ft=n("code"),Ls=s("IterableDataset"),zs=s(" conceptual guide."),Kt=c(),y=n("p"),Os=s("To get more hands-on with these datasets types, check out the "),Ge=n("a"),Hs=s("Process"),Ys=s(" guide to learn how to preprocess a "),Le=n("a"),Rs=s("Dataset"),Ms=s(" or the "),ze=n("a"),Ks=s("Stream"),Us=s(" guide to learn how to preprocess an "),Oe=n("a"),Ws=s("IterableDataset"),Qs=s("."),this.h()},l(e){const i=an('[data-svelte="svelte-1phssyn"]',document.head);S=r(i,"META",{name:!0,content:!0}),i.forEach(a),ut=d(e),T=r(e,"H1",{class:!0});var Wt=o(T);L=r(Wt,"A",{id:!0,class:!0,href:!0});var Xs=o(L);Ke=r(Xs,"SPAN",{});var Zs=o(Ke);u(Z.$$.fragment,Zs),Zs.forEach(a),Xs.forEach(a),oa=d(Wt),Ue=r(Wt,"SPAN",{});var el=o(Ue);ia=l(el,"Know your dataset"),el.forEach(a),Wt.forEach(a),gt=d(e),x=r(e,"P",{});var I=o(x);pa=l(I,"There are two types of dataset objects, a regular "),ge=r(I,"A",{href:!0});var tl=o(ge);ha=l(tl,"Dataset"),tl.forEach(a),ca=l(I," and then an \u2728 "),ve=r(I,"A",{href:!0});var al=o(ve);da=l(al,"IterableDataset"),al.forEach(a),fa=l(I," \u2728. A "),be=r(I,"A",{href:!0});var sl=o(be);ma=l(sl,"Dataset"),sl.forEach(a),ua=l(I," provides fast random access to the rows, and memory-mapping so that loading even large datasets only uses a relatively small amount of device memory. But for really, really big datasets that won\u2019t even fit on disk or in memory, an "),we=r(I,"A",{href:!0});var ll=o(we);ga=l(ll,"IterableDataset"),ll.forEach(a),va=l(I," allows you to access and use the dataset without waiting for it to download completely!"),I.forEach(a),vt=d(e),k=r(e,"P",{});var He=o(k);ba=l(He,"This tutorial will show you how to load and access a "),xe=r(He,"A",{href:!0});var nl=o(xe);wa=l(nl,"Dataset"),nl.forEach(a),xa=l(He," and an "),_e=r(He,"A",{href:!0});var rl=o(_e);_a=l(rl,"IterableDataset"),rl.forEach(a),ya=l(He,"."),He.forEach(a),bt=d(e),F=r(e,"H2",{class:!0});var Qt=o(F);z=r(Qt,"A",{id:!0,class:!0,href:!0});var ol=o(z);We=r(ol,"SPAN",{});var il=o(We);u(ee.$$.fragment,il),il.forEach(a),ol.forEach(a),ja=d(Qt),Qe=r(Qt,"SPAN",{});var pl=o(Qe);$a=l(pl,"Dataset"),pl.forEach(a),Qt.forEach(a),wt=d(e),E=r(e,"P",{});var Ye=o(E);ka=l(Ye,"When you load a dataset split, you\u2019ll get a "),ye=r(Ye,"A",{href:!0});var hl=o(ye);Ea=l(hl,"Dataset"),hl.forEach(a),Da=l(Ye," object. You can do many things with a "),je=r(Ye,"A",{href:!0});var cl=o(je);Ia=l(cl,"Dataset"),cl.forEach(a),Aa=l(Ye," object, which is why it\u2019s important to learn how to manipulate and interact with the data stored inside."),Ye.forEach(a),xt=d(e),O=r(e,"P",{});var Vt=o(O);Pa=l(Vt,"This tutorial uses the "),te=r(Vt,"A",{href:!0,rel:!0});var dl=o(te);qa=l(dl,"rotten_tomatoes"),dl.forEach(a),Sa=l(Vt," dataset, but feel free to load any dataset you\u2019d like and follow along!"),Vt.forEach(a),_t=d(e),u(ae.$$.fragment,e),yt=d(e),B=r(e,"H3",{class:!0});var Xt=o(B);H=r(Xt,"A",{id:!0,class:!0,href:!0});var fl=o(H);Ve=r(fl,"SPAN",{});var ml=o(Ve);u(se.$$.fragment,ml),ml.forEach(a),fl.forEach(a),Ta=d(Xt),Xe=r(Xt,"SPAN",{});var ul=o(Xe);Fa=l(ul,"Indexing"),ul.forEach(a),Xt.forEach(a),jt=d(e),D=r(e,"P",{});var Re=o(D);Ba=l(Re,"A "),$e=r(Re,"A",{href:!0});var gl=o($e);Na=l(gl,"Dataset"),gl.forEach(a),Ca=l(Re," contains columns of data, and each column can be a different type of data. The "),Ze=r(Re,"EM",{});var vl=o(Ze);Ja=l(vl,"index"),vl.forEach(a),Ga=l(Re,", or axis label, is used to access examples from the dataset. For example, indexing by the row returns a dictionary of an example from the dataset:"),Re.forEach(a),$t=d(e),u(le.$$.fragment,e),kt=d(e),Y=r(e,"P",{});var Zt=o(Y);La=l(Zt,"Use the "),et=r(Zt,"CODE",{});var bl=o(et);za=l(bl,"-"),bl.forEach(a),Oa=l(Zt," operator to start from the end of the dataset:"),Zt.forEach(a),Et=d(e),u(ne.$$.fragment,e),Dt=d(e),ke=r(e,"P",{});var wl=o(ke);Ha=l(wl,"Indexing by the column name returns a list of all the values in the column:"),wl.forEach(a),It=d(e),u(re.$$.fragment,e),At=d(e),Ee=r(e,"P",{});var xl=o(Ee);Ya=l(xl,"You can combine row and column name indexing to return a specific value at a position:"),xl.forEach(a),Pt=d(e),u(oe.$$.fragment,e),qt=d(e),De=r(e,"P",{});var _l=o(De);Ra=l(_l,"But it is important to remember that indexing order matters, especially when working with large audio and image datasets. Indexing by the column name returns all the values in the column first, then loads the value at that position. For large datasets, it may be slower to index by the column name first."),_l.forEach(a),St=d(e),u(ie.$$.fragment,e),Tt=d(e),N=r(e,"H3",{class:!0});var ea=o(N);R=r(ea,"A",{id:!0,class:!0,href:!0});var yl=o(R);tt=r(yl,"SPAN",{});var jl=o(tt);u(pe.$$.fragment,jl),jl.forEach(a),yl.forEach(a),Ma=d(ea),at=r(ea,"SPAN",{});var $l=o(at);Ka=l($l,"Slicing"),$l.forEach(a),ea.forEach(a),Ft=d(e),M=r(e,"P",{});var ta=o(M);Ua=l(ta,"Slicing returns a slice - or subset - of the dataset, which is useful for viewing several rows at once. To slice a dataset, use the "),st=r(ta,"CODE",{});var kl=o(st);Wa=l(kl,":"),kl.forEach(a),Qa=l(ta," operator to specify a range of positions."),ta.forEach(a),Bt=d(e),u(he.$$.fragment,e),Nt=d(e),C=r(e,"H2",{class:!0});var aa=o(C);K=r(aa,"A",{id:!0,class:!0,href:!0});var El=o(K);lt=r(El,"SPAN",{});var Dl=o(lt);u(ce.$$.fragment,Dl),Dl.forEach(a),El.forEach(a),Va=d(aa),nt=r(aa,"SPAN",{});var Il=o(nt);Xa=l(Il,"IterableDataset"),Il.forEach(a),aa.forEach(a),Ct=d(e),_=r(e,"P",{});var A=o(_);Za=l(A,"An "),Ie=r(A,"A",{href:!0});var Al=o(Ie);es=l(Al,"IterableDataset"),Al.forEach(a),ts=l(A," is loaded when you set the "),rt=r(A,"CODE",{});var Pl=o(rt);as=l(Pl,"streaming"),Pl.forEach(a),ss=l(A," parameter to "),ot=r(A,"CODE",{});var ql=o(ot);ls=l(ql,"True"),ql.forEach(a),ns=l(A," in "),Ae=r(A,"A",{href:!0});var Sl=o(Ae);rs=l(Sl,"load_dataset()"),Sl.forEach(a),os=l(A,":"),A.forEach(a),Jt=d(e),u(de.$$.fragment,e),Gt=d(e),U=r(e,"P",{});var sa=o(U);is=l(sa,"An "),Pe=r(sa,"A",{href:!0});var Tl=o(Pe);ps=l(Tl,"IterableDataset"),Tl.forEach(a),hs=l(sa," progressively iterates over a dataset one example at a time, so you don\u2019t have to wait for the whole dataset to download before you can use it. As you can imagine, this is quite useful for large datasets you want to use immediately!"),sa.forEach(a),Lt=d(e),f=r(e,"P",{});var j=o(f);cs=l(j,"However, this means an "),qe=r(j,"A",{href:!0});var Fl=o(qe);ds=l(Fl,"IterableDataset"),Fl.forEach(a),fs=l(j,"\u2019s behavior is different from a regular "),Se=r(j,"A",{href:!0});var Bl=o(Se);ms=l(Bl,"Dataset"),Bl.forEach(a),us=l(j,". You don\u2019t get random access to examples in an "),Te=r(j,"A",{href:!0});var Nl=o(Te);gs=l(Nl,"IterableDataset"),Nl.forEach(a),vs=l(j,". Instead, you should iterate over its elements, for example, by calling "),it=r(j,"CODE",{});var Cl=o(it);bs=l(Cl,"next(iter())"),Cl.forEach(a),ws=l(j," or with a "),pt=r(j,"CODE",{});var Jl=o(pt);xs=l(Jl,"for"),Jl.forEach(a),_s=l(j," loop to return the next item from the "),Fe=r(j,"A",{href:!0});var Gl=o(Fe);ys=l(Gl,"IterableDataset"),Gl.forEach(a),js=l(j,":"),j.forEach(a),zt=d(e),u(fe.$$.fragment,e),Ot=d(e),W=r(e,"P",{});var la=o(W);$s=l(la,"You can return a subset of the dataset with a specific number of examples in it with "),Be=r(la,"A",{href:!0});var Ll=o(Be);ks=l(Ll,"IterableDataset.take()"),Ll.forEach(a),Es=l(la,":"),la.forEach(a),Ht=d(e),u(me.$$.fragment,e),Yt=d(e),$=r(e,"P",{});var X=o($);Ds=l(X,"But unlike "),Ne=r(X,"A",{href:!0});var zl=o(Ne);Is=l(zl,"slicing"),zl.forEach(a),As=l(X,", "),Ce=r(X,"A",{href:!0});var Ol=o(Ce);Ps=l(Ol,"IterableDataset.take()"),Ol.forEach(a),qs=l(X," creates a new "),Je=r(X,"A",{href:!0});var Hl=o(Je);Ss=l(Hl,"IterableDataset"),Hl.forEach(a),Ts=l(X,"."),X.forEach(a),Rt=d(e),J=r(e,"H2",{class:!0});var na=o(J);Q=r(na,"A",{id:!0,class:!0,href:!0});var Yl=o(Q);ht=r(Yl,"SPAN",{});var Rl=o(ht);u(ue.$$.fragment,Rl),Rl.forEach(a),Yl.forEach(a),Fs=d(na),ct=r(na,"SPAN",{});var Ml=o(ct);Bs=l(Ml,"Next steps"),Ml.forEach(a),na.forEach(a),Mt=d(e),V=r(e,"P",{});var ra=o(V);Ns=l(ra,"Interested in learning more about the differences between these two types of datasets? Learn more about them in the "),G=r(ra,"A",{href:!0});var mt=o(G);Cs=l(mt,"Differences between "),dt=r(mt,"CODE",{});var Kl=o(dt);Js=l(Kl,"Dataset"),Kl.forEach(a),Gs=l(mt," and "),ft=r(mt,"CODE",{});var Ul=o(ft);Ls=l(Ul,"IterableDataset"),Ul.forEach(a),mt.forEach(a),zs=l(ra," conceptual guide."),ra.forEach(a),Kt=d(e),y=r(e,"P",{});var P=o(y);Os=l(P,"To get more hands-on with these datasets types, check out the "),Ge=r(P,"A",{href:!0});var Wl=o(Ge);Hs=l(Wl,"Process"),Wl.forEach(a),Ys=l(P," guide to learn how to preprocess a "),Le=r(P,"A",{href:!0});var Ql=o(Le);Rs=l(Ql,"Dataset"),Ql.forEach(a),Ms=l(P," or the "),ze=r(P,"A",{href:!0});var Vl=o(ze);Ks=l(Vl,"Stream"),Vl.forEach(a),Us=l(P," guide to learn how to preprocess an "),Oe=r(P,"A",{href:!0});var Xl=o(Oe);Ws=l(Xl,"IterableDataset"),Xl.forEach(a),Qs=l(P,"."),P.forEach(a),this.h()},h(){h(S,"name","hf:doc:metadata"),h(S,"content",JSON.stringify(rn)),h(L,"id","know-your-dataset"),h(L,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(L,"href","#know-your-dataset"),h(T,"class","relative group"),h(ge,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(ve,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(be,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(we,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(xe,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(_e,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(z,"id","dataset"),h(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(z,"href","#dataset"),h(F,"class","relative group"),h(ye,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(je,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(te,"href","https://huggingface.co/datasets/rotten_tomatoes"),h(te,"rel","nofollow"),h(H,"id","indexing"),h(H,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(H,"href","#indexing"),h(B,"class","relative group"),h($e,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(R,"id","slicing"),h(R,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(R,"href","#slicing"),h(N,"class","relative group"),h(K,"id","iterabledataset"),h(K,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(K,"href","#iterabledataset"),h(C,"class","relative group"),h(Ie,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Ae,"href","/docs/datasets/v2.11.0/en/package_reference/loading_methods#datasets.load_dataset"),h(Pe,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(qe,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Se,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(Te,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Fe,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Be,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.take"),h(Ne,"href","access/#slicing"),h(Ce,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.take"),h(Je,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Q,"id","next-steps"),h(Q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Q,"href","#next-steps"),h(J,"class","relative group"),h(G,"href","about_mapstyle_vs_iterable"),h(Ge,"href","process"),h(Le,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(ze,"href","stream"),h(Oe,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset")},m(e,i){t(document.head,S),p(e,ut,i),p(e,T,i),t(T,L),t(L,Ke),g(Z,Ke,null),t(T,oa),t(T,Ue),t(Ue,ia),p(e,gt,i),p(e,x,i),t(x,pa),t(x,ge),t(ge,ha),t(x,ca),t(x,ve),t(ve,da),t(x,fa),t(x,be),t(be,ma),t(x,ua),t(x,we),t(we,ga),t(x,va),p(e,vt,i),p(e,k,i),t(k,ba),t(k,xe),t(xe,wa),t(k,xa),t(k,_e),t(_e,_a),t(k,ya),p(e,bt,i),p(e,F,i),t(F,z),t(z,We),g(ee,We,null),t(F,ja),t(F,Qe),t(Qe,$a),p(e,wt,i),p(e,E,i),t(E,ka),t(E,ye),t(ye,Ea),t(E,Da),t(E,je),t(je,Ia),t(E,Aa),p(e,xt,i),p(e,O,i),t(O,Pa),t(O,te),t(te,qa),t(O,Sa),p(e,_t,i),g(ae,e,i),p(e,yt,i),p(e,B,i),t(B,H),t(H,Ve),g(se,Ve,null),t(B,Ta),t(B,Xe),t(Xe,Fa),p(e,jt,i),p(e,D,i),t(D,Ba),t(D,$e),t($e,Na),t(D,Ca),t(D,Ze),t(Ze,Ja),t(D,Ga),p(e,$t,i),g(le,e,i),p(e,kt,i),p(e,Y,i),t(Y,La),t(Y,et),t(et,za),t(Y,Oa),p(e,Et,i),g(ne,e,i),p(e,Dt,i),p(e,ke,i),t(ke,Ha),p(e,It,i),g(re,e,i),p(e,At,i),p(e,Ee,i),t(Ee,Ya),p(e,Pt,i),g(oe,e,i),p(e,qt,i),p(e,De,i),t(De,Ra),p(e,St,i),g(ie,e,i),p(e,Tt,i),p(e,N,i),t(N,R),t(R,tt),g(pe,tt,null),t(N,Ma),t(N,at),t(at,Ka),p(e,Ft,i),p(e,M,i),t(M,Ua),t(M,st),t(st,Wa),t(M,Qa),p(e,Bt,i),g(he,e,i),p(e,Nt,i),p(e,C,i),t(C,K),t(K,lt),g(ce,lt,null),t(C,Va),t(C,nt),t(nt,Xa),p(e,Ct,i),p(e,_,i),t(_,Za),t(_,Ie),t(Ie,es),t(_,ts),t(_,rt),t(rt,as),t(_,ss),t(_,ot),t(ot,ls),t(_,ns),t(_,Ae),t(Ae,rs),t(_,os),p(e,Jt,i),g(de,e,i),p(e,Gt,i),p(e,U,i),t(U,is),t(U,Pe),t(Pe,ps),t(U,hs),p(e,Lt,i),p(e,f,i),t(f,cs),t(f,qe),t(qe,ds),t(f,fs),t(f,Se),t(Se,ms),t(f,us),t(f,Te),t(Te,gs),t(f,vs),t(f,it),t(it,bs),t(f,ws),t(f,pt),t(pt,xs),t(f,_s),t(f,Fe),t(Fe,ys),t(f,js),p(e,zt,i),g(fe,e,i),p(e,Ot,i),p(e,W,i),t(W,$s),t(W,Be),t(Be,ks),t(W,Es),p(e,Ht,i),g(me,e,i),p(e,Yt,i),p(e,$,i),t($,Ds),t($,Ne),t(Ne,Is),t($,As),t($,Ce),t(Ce,Ps),t($,qs),t($,Je),t(Je,Ss),t($,Ts),p(e,Rt,i),p(e,J,i),t(J,Q),t(Q,ht),g(ue,ht,null),t(J,Fs),t(J,ct),t(ct,Bs),p(e,Mt,i),p(e,V,i),t(V,Ns),t(V,G),t(G,Cs),t(G,dt),t(dt,Js),t(G,Gs),t(G,ft),t(ft,Ls),t(V,zs),p(e,Kt,i),p(e,y,i),t(y,Os),t(y,Ge),t(Ge,Hs),t(y,Ys),t(y,Le),t(Le,Rs),t(y,Ms),t(y,ze),t(ze,Ks),t(y,Us),t(y,Oe),t(Oe,Ws),t(y,Qs),Ut=!0},p:sn,i(e){Ut||(v(Z.$$.fragment,e),v(ee.$$.fragment,e),v(ae.$$.fragment,e),v(se.$$.fragment,e),v(le.$$.fragment,e),v(ne.$$.fragment,e),v(re.$$.fragment,e),v(oe.$$.fragment,e),v(ie.$$.fragment,e),v(pe.$$.fragment,e),v(he.$$.fragment,e),v(ce.$$.fragment,e),v(de.$$.fragment,e),v(fe.$$.fragment,e),v(me.$$.fragment,e),v(ue.$$.fragment,e),Ut=!0)},o(e){b(Z.$$.fragment,e),b(ee.$$.fragment,e),b(ae.$$.fragment,e),b(se.$$.fragment,e),b(le.$$.fragment,e),b(ne.$$.fragment,e),b(re.$$.fragment,e),b(oe.$$.fragment,e),b(ie.$$.fragment,e),b(pe.$$.fragment,e),b(he.$$.fragment,e),b(ce.$$.fragment,e),b(de.$$.fragment,e),b(fe.$$.fragment,e),b(me.$$.fragment,e),b(ue.$$.fragment,e),Ut=!1},d(e){a(S),e&&a(ut),e&&a(T),w(Z),e&&a(gt),e&&a(x),e&&a(vt),e&&a(k),e&&a(bt),e&&a(F),w(ee),e&&a(wt),e&&a(E),e&&a(xt),e&&a(O),e&&a(_t),w(ae,e),e&&a(yt),e&&a(B),w(se),e&&a(jt),e&&a(D),e&&a($t),w(le,e),e&&a(kt),e&&a(Y),e&&a(Et),w(ne,e),e&&a(Dt),e&&a(ke),e&&a(It),w(re,e),e&&a(At),e&&a(Ee),e&&a(Pt),w(oe,e),e&&a(qt),e&&a(De),e&&a(St),w(ie,e),e&&a(Tt),e&&a(N),w(pe),e&&a(Ft),e&&a(M),e&&a(Bt),w(he,e),e&&a(Nt),e&&a(C),w(ce),e&&a(Ct),e&&a(_),e&&a(Jt),w(de,e),e&&a(Gt),e&&a(U),e&&a(Lt),e&&a(f),e&&a(zt),w(fe,e),e&&a(Ot),e&&a(W),e&&a(Ht),w(me,e),e&&a(Yt),e&&a($),e&&a(Rt),e&&a(J),w(ue),e&&a(Mt),e&&a(V),e&&a(Kt),e&&a(y)}}}const rn={local:"know-your-dataset",sections:[{local:"dataset",sections:[{local:"indexing",title:"Indexing"},{local:"slicing",title:"Slicing"}],title:"Dataset"},{local:"iterabledataset",title:"IterableDataset"},{local:"next-steps",title:"Next steps"}],title:"Know your dataset"};function on(Vs){return ln(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class dn extends Zl{constructor(S){super();en(this,S,on,nn,tn,{})}}export{dn as default,rn as metadata};
