Chalk DataFrames
Install Chalk DataFrames and calculate spending by user.
Install chalkdf with uv pip on Python 3.11 through 3.15 on Linux or macOS 15 or later.
uv pip install chalkdfStart a Python session. Create three transactions, then select the columns needed to calculate spending. Keep transactions of at least 10 and sum them by user.
from chalk import _
from chalkdf import DataFrame
tx = DataFrame({"user": ["a", "a", "b"], "amount": [12, 8, 30]})
totals = (
tx.select("user", "amount")
.filter(_.amount >= 10)
.agg(["user"], _.amount.sum().alias("total"))
)
users = DataFrame({"user": ["a", "b"], "name": ["Ari", "Bo"]})
totals.join(users, on=["user"], how="inner").select("name", "total").order_by("name").run()| # | namestring | totalint64 |
|---|---|---|
| 1 | Ari | 12 |
| 2 | Bo | 30 |
The transaction for 8 drops out before the aggregation. Call run() to execute the plan and inspect its rows. The join attaches the name for each user. For other ways to match records, see Joins and as-of joins. To start from a file, see Files.
Read Expressions and contexts to learn how _ refers to the input of each operation. Browse the API reference for method signatures.
To submit a DataFrame plan to a worker and retrieve its results, see Run Remotely.
Use a deployed function’s return value as a DataFrame column with F.catalog_call. Pass the input columns as arguments, then submit the plan to Chalk. The catalog call guide shows a complete remote query and a static resolver that extracts named entities from transaction memos.