call_report.fca.layout.infer_field_dtype#

call_report.fca.layout.infer_field_dtype(*, var_type: Literal['Numeric', 'Alphanum.'], decimal_position: int) DType[source]#

Translate an FCA layout variable’s declared type into a narwhals dtype.

FCA’s own vocabulary is just "Numeric" or "Alphanum." plus a decimal position. This maps that onto the narwhals dtype vocabulary call_report.core.FieldVersion expects, using the same "Numeric"-specific check that fca.reader’s value-level casting applies. Anything other than "Numeric" is treated as text.

Parameters:
var_type{“Numeric”, “Alphanum.”}

The variable’s declared type, from its layout.

decimal_positionint

The variable’s declared decimal position, from its layout.

Returns:
narwhals.dtypes.DType

narwhals.Int64 for "Numeric" with decimal_position 0, narwhals.Float64 for "Numeric" with any other decimal_position, and narwhals.String for "Alphanum.".

Examples

>>> infer_field_dtype(var_type="Numeric", decimal_position=0)
Int64
>>> infer_field_dtype(var_type="Numeric", decimal_position=2)
Float64
>>> infer_field_dtype(var_type="Alphanum.", decimal_position=0)
String