call_report.core.FieldVersion#

class call_report.core.FieldVersion(*, dtype: DType, definition: str, periods: PeriodRange)[source]#

Bases: object

One span of a field’s history where its dtype and definition held constant.

A FieldAttributes’s versions is one or more of these: most fields have exactly one, meaning their dtype and definition never changed across their whole known history. A field whose definition was revised in place, without ever disappearing, has one version per revision, with adjacent (non-gapped) periods.

Attributes:
dtypenarwhals.dtypes.DType

The field’s data type during this version, as an instantiated narwhals dtype (e.g. narwhals.Int64(), narwhals.String()). Translating a source’s own vocabulary (e.g. FCA’s "Numeric"/"Alphanum.") into a narwhals dtype is that source’s own responsibility. This class is shared across every source, so it only ever deals in narwhals’ vocabulary.

definitionstr

The field’s human-readable definition during this version, taken from the source’s layout file.

periodsPeriodRange

The contiguous span this version covers.

Examples

>>> import narwhals as nw
>>> from call_report.core import FieldVersion, PeriodRange
>>> version = FieldVersion(
...     dtype=nw.Int64(),
...     definition="Investment Code: 10 U.S. Treasury securities...",
...     periods=PeriodRange(start="2000-03-31", end="2014-12-31"),
... )
>>> version.periods[0].label
'2000Q1'