> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lancedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Polars

LanceDB supports [Polars](https://github.com/pola-rs/polars), a blazingly fast DataFrame library for Python written in Rust. Under the hood, both Lance and Polars speak Arrow, so passing data back and forth stays zero-copy and ergonomic.

## Create & Query a Table

Import the required libraries, including the optional Pydantic helpers if you plan to define schemas.

import tempfile
from pathlib import Path

import lancedb
import polars as pl
from lancedb.pydantic import LanceModel, Vector


Build a Polars `DataFrame`, convert it to Arrow, and use it directly when creating a LanceDB table.

birds = pl.DataFrame(
&#x20;   \{
&#x20;       "text": \["phoenix", "sparrow"],
&#x20;       "vector": \[
&#x20;           \[0.1, 0.2, 0.3],
&#x20;           \[0.8, 0.6, 0.5],
&#x20;       ],
&#x20;   }
)
polars\_db = lancedb.connect(str(Path(tempfile.mkdtemp()) / "polars-demo"))
polars\_table = polars\_db.create\_table(
&#x20;   "birds", data=birds.to\_arrow(), mode="overwrite"
)


Run vector search and keep the results as a Polars `DataFrame` for further processing or visualization.

polars\_results = (
&#x20;   polars\_table.search(\[0.1, 0.2, 0.3])
&#x20;   .select(\["text", "\_distance"])
&#x20;   .limit(1)
&#x20;   .to\_polars()
)
print(polars\_results)


## Work with LazyFrames

When you want to operate on the entire table (potentially larger than RAM), convert to a Polars `LazyFrame` so you can chain transformations without loading everything at once.

lazy\_frame = polars\_table.to\_polars().lazy()
print(lazy\_frame.select(\["text"]).collect())


## Define Schemas with Pydantic

You can also describe your table via `LanceModel` and continue ingesting data from Polars. This is useful when multiple teams share a schema or when you want validation.

class BirdModel(LanceModel):
&#x20;   text: str
&#x20;   vector: Vector(3)

schema\_table = polars\_db.create\_table(
&#x20;   "birds\_schema", schema=BirdModel, mode="overwrite"
)
schema\_table.add(birds.to\_dicts())


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.