import{s as $e,o as ge,n as ye}from"../chunks/scheduler.d6170356.js";import{S as we,i as Te,g as o,s as l,r as u,A as ve,h as r,f as a,c as n,j as ce,u as d,x as m,k as he,y as _e,a as s,v as c,d as h,t as $,w as g}from"../chunks/index.fcd4cc08.js";import{T as be}from"../chunks/Tip.b09c67cf.js";import{C as ae}from"../chunks/CodeBlock.7b16bdef.js";import{H as se,E as Me}from"../chunks/EditOnGithub.da2b595c.js";function Pe(z){let i,y='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=y},l(p){i=r(p,"P",{"data-svelte-h":!0}),m(i)!=="svelte-12afnf0"&&(i.innerHTML=y)},m(p,U){s(p,i,U)},p:ye,d(p){p&&a(i)}}}function Le(z){let i,y,p,U,w,A,T,le='<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>.',j,v,ne='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>)',W,_,Z,b,ie="To get started, you can simply <code>pip install</code> Polars into your environment:",I,M,X,P,oe="Once you have installed Polars, you can directly query a dataset based on a Hugging Face URL. No other dependencies are needed for this.",Y,L,S,f,V,H,re="Polars supports globbing to download multiple files at once into a single DataFrame.",E,J,N,q,B,x,pe="A Hugging Face URL can be constructed from the <code>username</code> and <code>dataset</code> name like this:",D,G,me="<li><code>hf://datasets/{username}/{dataset}/{path_to_file}</code></li>",O,C,fe='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>:',Q,k,ue="<li><code>hf://datasets/{my-username}/{my-dataset}@~parquet/{path_to_file}</code></li>",K,F,ee,R,te;return w=new se({props:{title:"Polars",local:"polars",headingTag:"h1"}}),_=new se({props:{title:"Getting started",local:"getting-started",headingTag:"h2"}}),M=new ae({props:{code:"cGlwJTIwaW5zdGFsbCUyMHBvbGFycw==",highlighted:'pip <span class="hljs-keyword">install</span> polars',wrap:!1}}),L=new ae({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}}),f=new be({props:{$$slots:{default:[Pe]},$$scope:{ctx:z}}}),J=new ae({props:{code:"cGwucmVhZF9wYXJxdWV0KCUyMmhmJTNBJTJGJTJGZGF0YXNldHMlMkZyb25lbmVsZGFuJTJGVGlueVN0b3JpZXMlMkZkYXRhJTJGdHJhaW4tKi5wYXJxdWV0JTIyKQ==",highlighted:'pl.read_parquet(<span class="hljs-string">&quot;hf://datasets/roneneldan/TinyStories/data/train-*.parquet&quot;</span>)',wrap:!1}}),q=new se({props:{title:"Hugging Face URLs",local:"hugging-face-urls",headingTag:"h3"}}),F=new Me({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/datasets-polars.md"}}),{c(){i=o("meta"),y=l(),p=o("p"),U=l(),u(w.$$.fragment),A=l(),T=o("p"),T.innerHTML=le,j=l(),v=o("p"),v.innerHTML=ne,W=l(),u(_.$$.fragment),Z=l(),b=o("p"),b.innerHTML=ie,I=l(),u(M.$$.fragment),X=l(),P=o("p"),P.textContent=oe,Y=l(),u(L.$$.fragment),S=l(),u(f.$$.fragment),V=l(),H=o("p"),H.textContent=re,E=l(),u(J.$$.fragment),N=l(),u(q.$$.fragment),B=l(),x=o("p"),x.innerHTML=pe,D=l(),G=o("ul"),G.innerHTML=me,O=l(),C=o("p"),C.innerHTML=fe,Q=l(),k=o("ul"),k.innerHTML=ue,K=l(),u(F.$$.fragment),ee=l(),R=o("p"),this.h()},l(e){const t=ve("svelte-u9bgzb",document.head);i=r(t,"META",{name:!0,content:!0}),t.forEach(a),y=n(e),p=r(e,"P",{}),ce(p).forEach(a),U=n(e),d(w.$$.fragment,e),A=n(e),T=r(e,"P",{"data-svelte-h":!0}),m(T)!=="svelte-1umk7lo"&&(T.innerHTML=le),j=n(e),v=r(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-vvd8j5"&&(v.innerHTML=ne),W=n(e),d(_.$$.fragment,e),Z=n(e),b=r(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-191zxjj"&&(b.innerHTML=ie),I=n(e),d(M.$$.fragment,e),X=n(e),P=r(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-lgvpmh"&&(P.textContent=oe),Y=n(e),d(L.$$.fragment,e),S=n(e),d(f.$$.fragment,e),V=n(e),H=r(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-7ocmoj"&&(H.textContent=re),E=n(e),d(J.$$.fragment,e),N=n(e),d(q.$$.fragment,e),B=n(e),x=r(e,"P",{"data-svelte-h":!0}),m(x)!=="svelte-3qw7md"&&(x.innerHTML=pe),D=n(e),G=r(e,"UL",{"data-svelte-h":!0}),m(G)!=="svelte-18836qw"&&(G.innerHTML=me),O=n(e),C=r(e,"P",{"data-svelte-h":!0}),m(C)!=="svelte-1xmbsoq"&&(C.innerHTML=fe),Q=n(e),k=r(e,"UL",{"data-svelte-h":!0}),m(k)!=="svelte-1qbjnl0"&&(k.innerHTML=ue),K=n(e),d(F.$$.fragment,e),ee=n(e),R=r(e,"P",{}),ce(R).forEach(a),this.h()},h(){he(i,"name","hf:doc:metadata"),he(i,"content",He)},m(e,t){_e(document.head,i),s(e,y,t),s(e,p,t),s(e,U,t),c(w,e,t),s(e,A,t),s(e,T,t),s(e,j,t),s(e,v,t),s(e,W,t),c(_,e,t),s(e,Z,t),s(e,b,t),s(e,I,t),c(M,e,t),s(e,X,t),s(e,P,t),s(e,Y,t),c(L,e,t),s(e,S,t),c(f,e,t),s(e,V,t),s(e,H,t),s(e,E,t),c(J,e,t),s(e,N,t),c(q,e,t),s(e,B,t),s(e,x,t),s(e,D,t),s(e,G,t),s(e,O,t),s(e,C,t),s(e,Q,t),s(e,k,t),s(e,K,t),c(F,e,t),s(e,ee,t),s(e,R,t),te=!0},p(e,[t]){const de={};t&2&&(de.$$scope={dirty:t,ctx:e}),f.$set(de)},i(e){te||(h(w.$$.fragment,e),h(_.$$.fragment,e),h(M.$$.fragment,e),h(L.$$.fragment,e),h(f.$$.fragment,e),h(J.$$.fragment,e),h(q.$$.fragment,e),h(F.$$.fragment,e),te=!0)},o(e){$(w.$$.fragment,e),$(_.$$.fragment,e),$(M.$$.fragment,e),$(L.$$.fragment,e),$(f.$$.fragment,e),$(J.$$.fragment,e),$(q.$$.fragment,e),$(F.$$.fragment,e),te=!1},d(e){e&&(a(y),a(p),a(U),a(A),a(T),a(j),a(v),a(W),a(Z),a(b),a(I),a(X),a(P),a(Y),a(S),a(V),a(H),a(E),a(N),a(B),a(x),a(D),a(G),a(O),a(C),a(Q),a(k),a(K),a(ee),a(R)),a(i),g(w,e),g(_,e),g(M,e),g(L,e),g(f,e),g(J,e),g(q,e),g(F,e)}}}const He='{"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 Je(z){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fe extends we{constructor(i){super(),Te(this,i,Je,Le,$e,{})}}export{Fe as component};
