Metadata-Version: 2.4
Name: ridgeai
Version: 0.1.0
Requires-Python: <3.14,>=3.11
Requires-Dist: anywidget>=0.9.0
Requires-Dist: duckdb>=1.4.0
Requires-Dist: polars>=1.0.0
Requires-Dist: pyarrow>=21.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Description-Content-Type: text/markdown

# Ridge AI Python

[Ridge AI](https://ridgedata.ai) Python client and interactive widgets for Jupyter Lab and Marimo.

## Installation

```sh
pip install ridgeai
```

## Widgets

### Table

Display an interactive data table with profiling and row selection.

```python
import ridgeai as ri

# From a Polars DataFrame
ri.Table(df)

# From a DuckDB connection
ri.Table(conn, table="my_table")

# With a custom query
ri.Table(conn, query="SELECT * FROM my_table WHERE value > 100")
```

#### Retrieve Selected Rows

```py
table = ri.Table(df)
table
```

After having selected one or more rows, you can extract the row values as follows:

```py
table.selected_rows
```

You can of course also observe changes:

```py
table.observe(names=["selected_rows"])
def on_selection_change(change):
    selection = change["new"]
    print(selection)
```

### Plot

Auto-generate a chart from your data.

```python
import ridgeai as ri

# From a Polars DataFrame (specify columns to plot)
ri.Plot(df, columns=["date", "revenue"])

# From a DuckDB connection
ri.Plot(conn, table="my_table", columns=["x", "y"])

# With a custom query
ri.Plot(conn, query="SELECT date, sum(revenue) FROM sales GROUP BY date")
```

### Dashboard

Render an interactive remote dashboard with AI-powered chat.

```python
import ridgeai as ri

ri.Dashboard(id="your-dashboard-id")
```

For this to work, you need a Ridge AI API key from https://app.ridgedata.ai.

Set it as an environment variable or in a `.env` file in your working directory:

```
RIDGE_AI_API_KEY=rk_your_api_key_here
```

Alternatively, pass it directly:

```python
ri.Dashboard(id="...", api_key="rk_...")
```

#### Local Dashboard

> [!WARNING]
> You can also render a local dashboard if you have the spec handy. However,
> only do this if you know what you're up to.

```python
import ridgeai as ri

ri.Dashboard(data=df, spec=my_spec)
```
