import{s as _e,o as be,n as Me}from"../chunks/scheduler.d6170356.js";import{S as He,i as Le,g as o,s as l,r as d,A as Pe,h as r,f as a,c as n,j as ve,u as c,x as p,k as ie,y as xe,a as s,v as h,d as g,t as $,w as y}from"../chunks/index.fcd4cc08.js";import{T as Je}from"../chunks/Tip.b09c67cf.js";import{C as oe}from"../chunks/CodeBlock.db16bf50.js";import{H as re,E as qe}from"../chunks/getInferenceSnippets.0f6acb26.js";function Ce(j){let i,T='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-vs-eager/" rel="nofollow">Polars user guide</a>.';return{c(){i=o("p"),i.innerHTML=T},l(f){i=r(f,"P",{"data-svelte-h":!0}),p(i)!=="svelte-12afnf0"&&(i.innerHTML=T)},m(f,R){s(f,i,R)},p:Me,d(f){f&&a(i)}}}function Ge(j){let i,T,f,R,w,W,v,pe='<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>.',I,_,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>)',Z,b,ue="You can use the Hugging Face paths (<code>hf://</code>) to access data on the Hub:",X,u,me='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/polars_hf.png"/>',Y,M,V,H,de="To get started, you can simply <code>pip install</code> Polars into your environment:",S,L,E,P,ce="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,x,N,m,B,J,he="Polars supports globbing to download multiple files at once into a single DataFrame.",O,q,Q,C,K,G,ge="A Hugging Face URL can be constructed from the <code>username</code> and <code>dataset</code> name like this:",ee,F,$e="<li><code>hf://datasets/{username}/{dataset}/{path_to_file}</code></li>",te,k,ye='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>:',ae,z,Te="<li><code>hf://datasets/{my-username}/{my-dataset}@~parquet/{path_to_file}</code></li>",se,U,le,A,ne;return w=new re({props:{title:"Polars",local:"polars",headingTag:"h1"}}),M=new re({props:{title:"Getting started",local:"getting-started",headingTag:"h2"}}),L=new oe({props:{code:"cGlwJTIwaW5zdGFsbCUyMHBvbGFycw==",highlighted:"pip install polars",wrap:!1}}),x=new oe({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}}),m=new Je({props:{$$slots:{default:[Ce]},$$scope:{ctx:j}}}),q=new oe({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 re({props:{title:"Hugging Face URLs",local:"hugging-face-urls",headingTag:"h3"}}),U=new qe({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/datasets-polars.md"}}),{c(){i=o("meta"),T=l(),f=o("p"),R=l(),d(w.$$.fragment),W=l(),v=o("p"),v.innerHTML=pe,I=l(),_=o("p"),_.innerHTML=fe,Z=l(),b=o("p"),b.innerHTML=ue,X=l(),u=o("div"),u.innerHTML=me,Y=l(),d(M.$$.fragment),V=l(),H=o("p"),H.innerHTML=de,S=l(),d(L.$$.fragment),E=l(),P=o("p"),P.textContent=ce,D=l(),d(x.$$.fragment),N=l(),d(m.$$.fragment),B=l(),J=o("p"),J.textContent=he,O=l(),d(q.$$.fragment),Q=l(),d(C.$$.fragment),K=l(),G=o("p"),G.innerHTML=ge,ee=l(),F=o("ul"),F.innerHTML=$e,te=l(),k=o("p"),k.innerHTML=ye,ae=l(),z=o("ul"),z.innerHTML=Te,se=l(),d(U.$$.fragment),le=l(),A=o("p"),this.h()},l(e){const t=Pe("svelte-u9bgzb",document.head);i=r(t,"META",{name:!0,content:!0}),t.forEach(a),T=n(e),f=r(e,"P",{}),ve(f).forEach(a),R=n(e),c(w.$$.fragment,e),W=n(e),v=r(e,"P",{"data-svelte-h":!0}),p(v)!=="svelte-1umk7lo"&&(v.innerHTML=pe),I=n(e),_=r(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-vvd8j5"&&(_.innerHTML=fe),Z=n(e),b=r(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-2d4d1n"&&(b.innerHTML=ue),X=n(e),u=r(e,"DIV",{class:!0,"data-svelte-h":!0}),p(u)!=="svelte-15zhz89"&&(u.innerHTML=me),Y=n(e),c(M.$$.fragment,e),V=n(e),H=r(e,"P",{"data-svelte-h":!0}),p(H)!=="svelte-191zxjj"&&(H.innerHTML=de),S=n(e),c(L.$$.fragment,e),E=n(e),P=r(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-lgvpmh"&&(P.textContent=ce),D=n(e),c(x.$$.fragment,e),N=n(e),c(m.$$.fragment,e),B=n(e),J=r(e,"P",{"data-svelte-h":!0}),p(J)!=="svelte-7ocmoj"&&(J.textContent=he),O=n(e),c(q.$$.fragment,e),Q=n(e),c(C.$$.fragment,e),K=n(e),G=r(e,"P",{"data-svelte-h":!0}),p(G)!=="svelte-3qw7md"&&(G.innerHTML=ge),ee=n(e),F=r(e,"UL",{"data-svelte-h":!0}),p(F)!=="svelte-18836qw"&&(F.innerHTML=$e),te=n(e),k=r(e,"P",{"data-svelte-h":!0}),p(k)!=="svelte-1xmbsoq"&&(k.innerHTML=ye),ae=n(e),z=r(e,"UL",{"data-svelte-h":!0}),p(z)!=="svelte-1qbjnl0"&&(z.innerHTML=Te),se=n(e),c(U.$$.fragment,e),le=n(e),A=r(e,"P",{}),ve(A).forEach(a),this.h()},h(){ie(i,"name","hf:doc:metadata"),ie(i,"content",Fe),ie(u,"class","flex justify-center")},m(e,t){xe(document.head,i),s(e,T,t),s(e,f,t),s(e,R,t),h(w,e,t),s(e,W,t),s(e,v,t),s(e,I,t),s(e,_,t),s(e,Z,t),s(e,b,t),s(e,X,t),s(e,u,t),s(e,Y,t),h(M,e,t),s(e,V,t),s(e,H,t),s(e,S,t),h(L,e,t),s(e,E,t),s(e,P,t),s(e,D,t),h(x,e,t),s(e,N,t),h(m,e,t),s(e,B,t),s(e,J,t),s(e,O,t),h(q,e,t),s(e,Q,t),h(C,e,t),s(e,K,t),s(e,G,t),s(e,ee,t),s(e,F,t),s(e,te,t),s(e,k,t),s(e,ae,t),s(e,z,t),s(e,se,t),h(U,e,t),s(e,le,t),s(e,A,t),ne=!0},p(e,[t]){const we={};t&2&&(we.$$scope={dirty:t,ctx:e}),m.$set(we)},i(e){ne||(g(w.$$.fragment,e),g(M.$$.fragment,e),g(L.$$.fragment,e),g(x.$$.fragment,e),g(m.$$.fragment,e),g(q.$$.fragment,e),g(C.$$.fragment,e),g(U.$$.fragment,e),ne=!0)},o(e){$(w.$$.fragment,e),$(M.$$.fragment,e),$(L.$$.fragment,e),$(x.$$.fragment,e),$(m.$$.fragment,e),$(q.$$.fragment,e),$(C.$$.fragment,e),$(U.$$.fragment,e),ne=!1},d(e){e&&(a(T),a(f),a(R),a(W),a(v),a(I),a(_),a(Z),a(b),a(X),a(u),a(Y),a(V),a(H),a(S),a(E),a(P),a(D),a(N),a(B),a(J),a(O),a(Q),a(K),a(G),a(ee),a(F),a(te),a(k),a(ae),a(z),a(se),a(le),a(A)),a(i),y(w,e),y(M,e),y(L,e),y(x,e),y(m,e),y(q,e),y(C,e),y(U,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 ke(j){return be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class We extends He{constructor(i){super(),Le(this,i,ke,Ge,_e,{})}}export{We as component};
