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: object

A 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; asset i’s value at decision date t is its row lag steps back in i’s own series (per-asset lag).

  • vintaged (vintage_col given): a [ref_date, asset, vintage, <chars...>] panel; asset i’s value at t is its real-time edge — latest ref_date whose vintage is available (vintage month + lag <= t), from that ref’s latest vintage (per-asset VintagedBlock). 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), nan where 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), nan where absent.

Row r is asset assets[r] at decision date dates[dpos[r]].