tensorize
Converts long, tidy tables into labelled N-d tensors: selected columns become dimensions, value columns fill cells, duplicate axes aggregate, and missing combinations become NaN.
Instructions
Condense a long/tidy table into a labelled N-d tensor: each column in axes becomes a dimension and each value column
fills the cells; several value columns add a trailing 'variable' dimension. Coordinates: numeric/datetime axes sort
numerically, text axes sort naturally (b2 before b10); sort=False keeps first-appearance order; order={'tenor': ['1m','3m','1y']}
pins an explicit order per axis. Duplicate axis combinations are aggregated with agg (mean|sum|first|last|max|min|median|count);
missing combinations become NaN. Note that a later reduce 'mean' over a dim averages cells, not underlying rows: to get a
row-weighted mean, tensorize agg='sum' and agg='count' and divide.
Example: tensorize('opts', axes=['date','strike','maturity_days'], values=['iv']) -> a date x strike x maturity volatility cube.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>",
"axes": "<axes>"
},
"name": "tensorize"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agg | No | mean | |
| axes | Yes | ||
| name | Yes | ||
| sort | No | ||
| order | No | ||
| values | No | ||
| new_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |