> ## 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

**Applies to:** Embedded ✅, Enterprise ✅

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 and Query a Table

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

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
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.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
import lancedb

birds = pl.DataFrame(
    {
        "text": ["phoenix", "sparrow"],
        "vector": [
            [0.1, 0.2, 0.3],
            [0.8, 0.6, 0.5],
        ],
    }
)
polars_db = lancedb.connect(str(Path(tempfile.mkdtemp()) / "polars-demo"))
polars_table = polars_db.create_table(
    "birds", data=birds.to_arrow(), mode="overwrite"
)
```

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

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
polars_results = (
    polars_table.search([0.1, 0.2, 0.3])
    .select(["text", "_distance"])
    .limit(1)
    .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. This works for LanceDB Embedded tables only; with LanceDB Enterprise, `search(...).to_polars()` returns an eager DataFrame of query results.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
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.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
class BirdModel(LanceModel):
    text: str
    vector: Vector(3)

schema_table = polars_db.create_table(
    "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.