call_report.fca.DomainDataset#
- class call_report.fca.DomainDataset(*, name: str, code_column: str, codes: tuple[DomainDatasetCode, ...], sources: tuple[DomainDatasetSource, ...], derived: tuple[DomainDatasetDerived, ...])[source]#
Bases:
objectA curated view assembled from several FCA Call Report schedules.
Returned by get_fca_domain_dataset. Describes which schedules compose the view, which code each row is keyed by, and what every output column is called.
- Attributes:
- namestr
The dataset’s own name, matching its FCADomainDataset member.
- code_columnstr
The value the reshaped frame’s
code_columncarries. A curated name, not any one schedule’s own code column.- codestuple[DomainDatasetCode, …]
Every code this dataset keys rows by.
- sourcestuple[DomainDatasetSource, …]
The schedule groups contributing columns.
- derivedtuple[DomainDatasetDerived, …]
Output columns computed from other output columns.
Examples
>>> from call_report.fca import FCADomainDataset, get_fca_domain_dataset >>> dataset = get_fca_domain_dataset(domain_dataset=FCADomainDataset.LOAN_PORTFOLIO) >>> dataset.name 'loan_portfolio'
- property schedules: tuple[str, ...][source]#
Return every schedule root name this dataset draws on.
Flattens the source groups back into one list, which is what a caller needs to decide which schedules to load. Grouping matters for naming, not for loading.
- Returns:
- tuple[str, …]
The root names, in declaration order.
Examples
>>> from call_report.fca import FCADomainDataset, get_fca_domain_dataset >>> dataset = get_fca_domain_dataset( ... domain_dataset=FCADomainDataset.LOAN_PORTFOLIO ... ) >>> dataset.schedules ('RCF1', 'RIE', 'RIE2')
- property total_codes: frozenset[int][source]#
Return the codes that are reported subtotals rather than members.
A subtotal row is a figure the source reports itself, not one this package computes, so it is included by default. Aggregating over every code without excluding these double counts.
- Returns:
- frozenset[int]
Every DomainDatasetCode.code whose is_total is True.
Examples
>>> from call_report.fca import FCADomainDataset, get_fca_domain_dataset >>> dataset = get_fca_domain_dataset( ... domain_dataset=FCADomainDataset.LOAN_PORTFOLIO ... ) >>> sorted(dataset.total_codes) [155]
- property source_by_schedule: Mapping[str, DomainDatasetSource][source]#
Return each schedule’s contributing source group, by root name.
Computed once and cached on this instance, since sources never changes after construction and DomainDataset instances themselves are already cached for the life of the process by get_fca_domain_dataset.
- Returns:
- Mapping[str, DomainDatasetSource]
Every schedule root name in schedules, mapped to the source group that declares it.
Examples
>>> from call_report.fca import FCADomainDataset, get_fca_domain_dataset >>> dataset = get_fca_domain_dataset( ... domain_dataset=FCADomainDataset.LOAN_PORTFOLIO ... ) >>> dataset.source_by_schedule["RCF1"].code_column 'LOANSTATUS'
- classmethod from_dict(*, data: dict[str, Any]) DomainDataset[source]#
Build a DomainDataset from one shipped definition’s parsed JSON.
Validates invariants a hand-authored definition can violate silently: that no two source groups declare the same output column, that each source’s per-variable code values agree with whether it declares its own code_column, that every derived column names a real DerivedOperation, and that a derived column’s components are a non-empty list of real source output columns rather than another derived column’s name.
A definition with a missing or misspelled key also raises SchemaError, and the message names the dataset. The parsers in call_report.core raise the same error for the same problem.
Within one source group, an output column name may repeat across variables. That is deliberate, and is how a schedule split maps to one continuous column.
- Parameters:
- datadict[str, Any]
One dataset definition’s parsed JSON.
- Returns:
- DomainDataset
The parsed definition.
- Raises:
- SchemaError
If data is malformed (a missing key, or a value of the wrong shape), if two source groups declare the same output column, if a source’s code_column disagrees with whether its variables declare a code, if a derived column names an operation other than
"sum"or"difference", or if a derived column’s components are empty or name something no source produces.
Examples
>>> from call_report.fca._domain_datasets import DomainDataset >>> data = { ... "name": "example", ... "code_column": "SEGMENT", ... "codes": [{"code": 1, "label": "One", "is_total": False}], ... "sources": [ ... { ... "schedules": ["RCF1"], ... "code_column": "LOANSTATUS", ... "columns": {"ACCR": {"column": "accruing"}}, ... } ... ], ... "derived": [], ... } >>> DomainDataset.from_dict(data=data).name 'example'