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

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.

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

pandas\_df = pd.DataFrame(
&#x20;   \[
&#x20;       \{"id": "1", "text": "dragon", "vector": \[0.9, 0.1, 0.3]},
&#x20;       \{"id": "2", "text": "griffin", "vector": \[0.4, 0.5, 0.2]},
&#x20;       \{"id": "3", "text": "phoenix", "vector": \[0.7, 0.3, 0.6]},
&#x20;   ]
)
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.

pandas\_results = (
&#x20;   pandas\_table.search(\[0.9, 0.1, 0.3])
&#x20;   .select(\["text", "\_distance"])
&#x20;   .limit(1)
&#x20;   .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.

async def run\_pandas\_async\_example() -> None:
&#x20;   async\_db = await lancedb.connect\_async(
&#x20;       str(Path(tempfile.mkdtemp()) / "pandas-async")
&#x20;   )
&#x20;   async\_df = pd.DataFrame(
&#x20;       \[
&#x20;           \{"id": "10", "text": "sage", "vector": \[0.6, 0.4, 0.8]},
&#x20;           \{"id": "11", "text": "bard", "vector": \[0.2, 0.7, 0.3]},
&#x20;       ]
&#x20;   )
&#x20;   async\_table = await async\_db.create\_table(
&#x20;       "creatures\_async", data=async\_df, mode="overwrite"
&#x20;   )
&#x20;   async\_results = await (
&#x20;       async\_table.search(\[0.6, 0.4, 0.8])
&#x20;       .select(\["text", "\_distance"])
&#x20;       .limit(1)
&#x20;       .to\_pandas()
&#x20;   )
&#x20;   print(async\_results)

asyncio.run(run\_pandas\_async\_example())


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