import{s as Me,n as Le,o as He}from"../chunks/scheduler.9cda857a.js";import{S as Pe,i as xe,e as i,s as n,c as f,h as qe,a as o,d as a,b as s,f as _e,g as d,j as r,k as oe,l as Ce,m as l,n as c,t as h,o as g,p as $}from"../chunks/index.f47f3121.js";import{C as Je}from"../chunks/CopyLLMTxtMenu.676ed699.js";import{C as re}from"../chunks/CodeBlock.24d62f98.js";import{H as pe,E as Ge}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.64d112fc.js";function ke(me){let p,j,U,A,y,W,w,I,T,ue='<a href="https://pola.rs/" rel="nofollow">Polars</a> is an in-memory DataFrame library on top of an <a href="https://en.wikipedia.org/wiki/Online_analytical_processing" rel="nofollow">OLAP</a> query engine. It is fast, easy to use, and <a href="https://github.com/pola-rs/polars/" rel="nofollow">open source</a>.',Z,v,fe='Starting from version <code>1.2.0</code>, Polars provides <em>native</em> support for the Hugging Face file system. This means that all the benefits of the Polars query optimizer (e.g. predicate and projection pushdown) are applied and Polars will only load the data necessary to complete the query. This significantly speeds up reading, especially for large datasets (see <a href="./datasets-polars-optimizations">optimizations</a>)',X,b,de="You can use the Hugging Face paths (<code>hf://</code>) to access data on the Hub:",Y,m,ce='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/polars_hf.png"/>',S,_,V,M,he="To get started, you can simply <code>pip install</code> Polars into your environment:",E,L,B,H,ge="Once you have installed Polars, you can directly query a dataset based on a Hugging Face URL. No other dependencies are needed for this.",D,P,N,u,$e='<p>Polars provides two APIs: a lazy API (<code>scan_parquet</code>) and an eager API (<code>read_parquet</code>). We recommend using the eager API for interactive workloads and the lazy API for performance as it allows for better query optimization. For more information on the topic, check out the <a href="https://docs.pola.rs/user-guide/concepts/lazy-api/#when-to-use-which" rel="nofollow">Polars user guide</a>.</p>',O,x,ye="Polars supports globbing to download multiple files at once into a single DataFrame.",Q,q,K,C,ee,J,we="A Hugging Face URL can be constructed from the <code>username</code> and <code>dataset</code> name like this:",te,G,Te="<li><code>hf://datasets/{username}/{dataset}/{path_to_file}</code></li>",ae,k,ve='The path may include globbing patterns such as <code>**/*.parquet</code> to query all the files matching the pattern. Additionally, for any non-supported <a href="./datasets-polars-file-formats">file formats</a> you can use the auto-converted parquet files that Hugging Face provides using the <code>@~parquet branch</code>:',le,F,be="<li><code>hf://datasets/{my-username}/{my-dataset}@~parquet/{path_to_file}</code></li>",ne,z,se,R,ie;return y=new Je({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new pe({props:{title:"Polars",local:"polars",headingTag:"h1"}}),_=new pe({props:{title:"Getting started",local:"getting-started",headingTag:"h2"}}),L=new re({props:{code:"cGlwJTIwaW5zdGFsbCUyMHBvbGFycw==",highlighted:"pip install polars",wrap:!1}}),P=new re({props:{code:"aW1wb3J0JTIwcG9sYXJzJTIwYXMlMjBwbCUwQSUwQXBsLnJlYWRfcGFycXVldCglMjJoZiUzQSUyRiUyRmRhdGFzZXRzJTJGcm9uZW5lbGRhbiUyRlRpbnlTdG9yaWVzJTJGZGF0YSUyRnRyYWluLTAwMDAwLW9mLTAwMDA0LTJkNWExNDY3ZmZmMTA4MWIucGFycXVldCUyMik=",highlighted:`<span class="hljs-keyword">import</span> polars <span class="hljs-keyword">as</span> pl

pl.read_parquet(<span class="hljs-string">&quot;hf://datasets/roneneldan/TinyStories/data/train-00000-of-00004-2d5a1467fff1081b.parquet&quot;</span>)`,wrap:!1}}),q=new re({props:{code:"cGwucmVhZF9wYXJxdWV0KCUyMmhmJTNBJTJGJTJGZGF0YXNldHMlMkZyb25lbmVsZGFuJTJGVGlueVN0b3JpZXMlMkZkYXRhJTJGdHJhaW4tKi5wYXJxdWV0JTIyKQ==",highlighted:'pl.read_parquet(<span class="hljs-string">&quot;hf://datasets/roneneldan/TinyStories/data/train-*.parquet&quot;</span>)',wrap:!1}}),C=new pe({props:{title:"Hugging Face URLs",local:"hugging-face-urls",headingTag:"h3"}}),z=new Ge({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/datasets-polars.md"}}),{c(){p=i("meta"),j=n(),U=i("p"),A=n(),f(y.$$.fragment),W=n(),f(w.$$.fragment),I=n(),T=i("p"),T.innerHTML=ue,Z=n(),v=i("p"),v.innerHTML=fe,X=n(),b=i("p"),b.innerHTML=de,Y=n(),m=i("div"),m.innerHTML=ce,S=n(),f(_.$$.fragment),V=n(),M=i("p"),M.innerHTML=he,E=n(),f(L.$$.fragment),B=n(),H=i("p"),H.textContent=ge,D=n(),f(P.$$.fragment),N=n(),u=i("blockquote"),u.innerHTML=$e,O=n(),x=i("p"),x.textContent=ye,Q=n(),f(q.$$.fragment),K=n(),f(C.$$.fragment),ee=n(),J=i("p"),J.innerHTML=we,te=n(),G=i("ul"),G.innerHTML=Te,ae=n(),k=i("p"),k.innerHTML=ve,le=n(),F=i("ul"),F.innerHTML=be,ne=n(),f(z.$$.fragment),se=n(),R=i("p"),this.h()},l(e){const t=qe("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(a),j=s(e),U=o(e,"P",{}),_e(U).forEach(a),A=s(e),d(y.$$.fragment,e),W=s(e),d(w.$$.fragment,e),I=s(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-1umk7lo"&&(T.innerHTML=ue),Z=s(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-vvd8j5"&&(v.innerHTML=fe),X=s(e),b=o(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-2d4d1n"&&(b.innerHTML=de),Y=s(e),m=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(m)!=="svelte-15zhz89"&&(m.innerHTML=ce),S=s(e),d(_.$$.fragment,e),V=s(e),M=o(e,"P",{"data-svelte-h":!0}),r(M)!=="svelte-191zxjj"&&(M.innerHTML=he),E=s(e),d(L.$$.fragment,e),B=s(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-lgvpmh"&&(H.textContent=ge),D=s(e),d(P.$$.fragment,e),N=s(e),u=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(u)!=="svelte-7hro14"&&(u.innerHTML=$e),O=s(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-7ocmoj"&&(x.textContent=ye),Q=s(e),d(q.$$.fragment,e),K=s(e),d(C.$$.fragment,e),ee=s(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-3qw7md"&&(J.innerHTML=we),te=s(e),G=o(e,"UL",{"data-svelte-h":!0}),r(G)!=="svelte-18836qw"&&(G.innerHTML=Te),ae=s(e),k=o(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1xmbsoq"&&(k.innerHTML=ve),le=s(e),F=o(e,"UL",{"data-svelte-h":!0}),r(F)!=="svelte-1qbjnl0"&&(F.innerHTML=be),ne=s(e),d(z.$$.fragment,e),se=s(e),R=o(e,"P",{}),_e(R).forEach(a),this.h()},h(){oe(p,"name","hf:doc:metadata"),oe(p,"content",Fe),oe(m,"class","flex justify-center"),oe(u,"class","tip")},m(e,t){Ce(document.head,p),l(e,j,t),l(e,U,t),l(e,A,t),c(y,e,t),l(e,W,t),c(w,e,t),l(e,I,t),l(e,T,t),l(e,Z,t),l(e,v,t),l(e,X,t),l(e,b,t),l(e,Y,t),l(e,m,t),l(e,S,t),c(_,e,t),l(e,V,t),l(e,M,t),l(e,E,t),c(L,e,t),l(e,B,t),l(e,H,t),l(e,D,t),c(P,e,t),l(e,N,t),l(e,u,t),l(e,O,t),l(e,x,t),l(e,Q,t),c(q,e,t),l(e,K,t),c(C,e,t),l(e,ee,t),l(e,J,t),l(e,te,t),l(e,G,t),l(e,ae,t),l(e,k,t),l(e,le,t),l(e,F,t),l(e,ne,t),c(z,e,t),l(e,se,t),l(e,R,t),ie=!0},p:Le,i(e){ie||(h(y.$$.fragment,e),h(w.$$.fragment,e),h(_.$$.fragment,e),h(L.$$.fragment,e),h(P.$$.fragment,e),h(q.$$.fragment,e),h(C.$$.fragment,e),h(z.$$.fragment,e),ie=!0)},o(e){g(y.$$.fragment,e),g(w.$$.fragment,e),g(_.$$.fragment,e),g(L.$$.fragment,e),g(P.$$.fragment,e),g(q.$$.fragment,e),g(C.$$.fragment,e),g(z.$$.fragment,e),ie=!1},d(e){e&&(a(j),a(U),a(A),a(W),a(I),a(T),a(Z),a(v),a(X),a(b),a(Y),a(m),a(S),a(V),a(M),a(E),a(B),a(H),a(D),a(N),a(u),a(O),a(x),a(Q),a(K),a(ee),a(J),a(te),a(G),a(ae),a(k),a(le),a(F),a(ne),a(se),a(R)),a(p),$(y,e),$(w,e),$(_,e),$(L,e),$(P,e),$(q,e),$(C,e),$(z,e)}}}const Fe='{"title":"Polars","local":"polars","sections":[{"title":"Getting started","local":"getting-started","sections":[{"title":"Hugging Face URLs","local":"hugging-face-urls","sections":[],"depth":3}],"depth":2}],"depth":1}';function ze(me){return He(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends Pe{constructor(p){super(),xe(this,p,ze,ke,Me,{})}}export{Ie as component};
