# pandas Integration

## Functions

### to_dataframe

```python
from aifastdb.pandas_ext import to_dataframe

df = to_dataframe(store.all())
df = to_dataframe(sg.list_persons())
df = to_dataframe(records, columns=["id", "name", "age"])
```

Convert any list of record dicts to a pandas DataFrame.

**Parameters:**

- `records` — Sequence of dicts (each becomes a row)
- `columns` — Optional column filter / ordering
- `drop_embedding` — If `True` (default), drop the `embedding` column

### graph_to_dataframes

```python
from aifastdb.pandas_ext import graph_to_dataframes

entities_df, relations_df = graph_to_dataframes(sg.export_graph())
```

Convert a `SocialGraphV2.export_graph()` result to two DataFrames.

### query_result_to_dataframe

```python
from aifastdb.pandas_ext import query_result_to_dataframe

df = query_result_to_dataframe(fed.query("store", query))
```

Convert a Federation query result to a DataFrame.

### embedding_matrix

```python
from aifastdb.pandas_ext import embedding_matrix
import numpy as np

matrix = embedding_matrix(store.all(), key="embedding")
# numpy.ndarray of shape (N, dim)
```

Extract embeddings from records as a 2D numpy array.

## Installation

```bash
pip install aifastdb[pandas]
```
