numeraire.core.data.CharBlock#
- class numeraire.core.data.CharBlock(panel: DataFrame, chars: Sequence[str], *, lag: int = 0, date_col: str = 'date', asset_col: str = 'asset', vintage_col: str | None = None, ref_col: str = 'ref_date')[source]#
Bases:
objectA per-asset
[t, i]characteristic source with its own PIT, joined into a panel view.The cross-sectional analog of a time-series
FeatureBlock: several heterogeneous per-stock predictor panels (e.g. two vendors’ characteristic sets) coexist, each with its own availability, and concatenate along the characteristic axis. Two modes:lagged (default): a tidy
[date, asset, <chars...>]panel; asseti’s value at decision datetis its rowlagsteps back ini’s own series (per-asset lag).vintaged (
vintage_colgiven): a[ref_date, asset, vintage, <chars...>]panel; asseti’s value attis its real-time edge — latestref_datewhose vintage is available (vintagemonth+ lag <= t), from that ref’s latest vintage (per-assetVintagedBlock). This makes per-stock characteristic revisions PIT-safe mechanically.
Resolved against a view’s decision dates at construction (each date uses only info available by it), so downstream needs no special-casing. Align identifiers to a common id before building it.
- __init__(panel: DataFrame, chars: Sequence[str], *, lag: int = 0, date_col: str = 'date', asset_col: str = 'asset', vintage_col: str | None = None, ref_col: str = 'ref_date') None[source]#
Methods
__init__(panel, chars, *[, lag, date_col, ...])resolve(dates, assets, dpos)Values known at each row's decision date:
(len(assets) x K),nanwhere absent.- resolve(dates: DatetimeIndex, assets: NDArray[object_], dpos: NDArray[int64]) NDArray[float64][source]#
Values known at each row’s decision date:
(len(assets) x K),nanwhere absent.Row
ris assetassets[r]at decision datedates[dpos[r]].