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

# Pandas and PyArrow

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

Because Lance is built on top of [Apache Arrow](https://arrow.apache.org/),
LanceDB fits naturally into Pandas-first workflows. You can ingest a `DataFrame`,
query it with LanceDB's vector operators, and keep working in Pandas without any glue code.

## Create a dataset

Start by importing LanceDB alongside your usual Pandas utilities and connect to a temporary database.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
import asyncio
import tempfile
from pathlib import Path

import lancedb
import pandas as pd
```

Use the familiar `pd.DataFrame` API to prepare your rows, then pass the entire frame to `db.create_table`.

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

pandas_df = pd.DataFrame(
    [
        {"id": "1", "text": "dragon", "vector": [0.9, 0.1, 0.3]},
        {"id": "2", "text": "griffin", "vector": [0.4, 0.5, 0.2]},
        {"id": "3", "text": "phoenix", "vector": [0.7, 0.3, 0.6]},
    ]
)
pandas_db = lancedb.connect(str(Path(tempfile.mkdtemp()) / "pandas-demo"))
pandas_table = pandas_db.create_table("creatures", data=pandas_df, mode="overwrite")
```

## Vector search

Queries can return Pandas frames as well, so you can immediately inspect the results or pipe them into downstream analytics.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
pandas_results = (
    pandas_table.search([0.9, 0.1, 0.3])
    .select(["text", "_distance"])
    .limit(1)
    .to_pandas()
)
print(pandas_results)
```

## Async API

For web services or background jobs that already rely on `asyncio`, use the asynchronous helpers to keep everything non-blocking.

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

async def run_pandas_async_example() -> pd.DataFrame:
    async_db = await lancedb.connect_async(
        str(Path(tempfile.mkdtemp()) / "pandas-async")
    )
    async_df = pd.DataFrame(
        [
            {"id": "10", "text": "sage", "vector": [0.6, 0.4, 0.8]},
            {"id": "11", "text": "bard", "vector": [0.2, 0.7, 0.3]},
        ]
    )
    async_table = await async_db.create_table(
        "creatures_async", data=async_df, mode="overwrite"
    )
    # An async search returns its query builder from an await
    query = await async_table.search([0.6, 0.4, 0.8])
    async_results = await query.select(["text", "_distance"]).limit(1).to_pandas()
    print(async_results)
    return async_results

async_results = asyncio.run(run_pandas_async_example())
```


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