group_zscore(frame, group, name=None, metadata=None)
Return row-wise z-scores within each group.
Parameters
- frame : Panel | Graph
- Input numeric
Panelor single-outputGraph. group : Panel | Graph - Matching
CategoryPanelcontaining row-wise group labels. name : str | None, defaultNone - Optional graph-node name. A generated name is used when omitted.
metadata : Mapping[str, Any] | None, default
None - Optional metadata stored on the graph node.
Returns
- Graph
- Lazy single-output graph. Call
.compute()to materialize aPanel.
Examples
import polars as pl
from bagelquant_core import CategoryPanel, Domain, Panel
from bagelquant_core.composer import group_zscore
domain = Domain(calendar=["2024-01-02"], universe=["a", "b", "c"])
factor = Panel.from_domain(
pl.DataFrame({
"time": ["2024-01-02"] * 3,
"asset_id": ["a", "b", "c"],
"value": [1.0, 3.0, 8.0],
}),
domain,
)
industry = CategoryPanel.from_domain(
pl.DataFrame({
"time": ["2024-01-02"] * 3,
"asset_id": ["a", "b", "c"],
"value": ["tech", "tech", "bank"],
}),
domain,
)
result = group_zscore(factor, industry).compute().data
print(result)
Notes
Inputs are aligned by (time, asset_id) before the operation runs.
Missing group labels are excluded from the group calculation.