call_report.fca.convert_long_format_to_wide_format#
- call_report.fca.convert_long_format_to_wide_format(*, long: NativeDataFrame, dataframe_type: None = None) NativeDataFrame[source]#
- call_report.fca.convert_long_format_to_wide_format(*, long: NativeDataFrame, dataframe_type: Literal['pandas']) pandas.DataFrame
- call_report.fca.convert_long_format_to_wide_format(*, long: NativeDataFrame, dataframe_type: Literal['pyarrow_table']) pyarrow.Table
- call_report.fca.convert_long_format_to_wide_format(*, long: NativeDataFrame, dataframe_type: Literal['polars_dataframe']) polars.DataFrame
- call_report.fca.convert_long_format_to_wide_format(*, long: NativeDataFrame, dataframe_type: Literal['polars_lazyframe']) polars.LazyFrame
Convert an already-built long-format frame to wide format.
This function is self-contained. It builds each row’s wide column name with _with_column_key, then pivots with call_report.core._backend.pivot. Pivoting requires the (UNINUM, period, column_key) grain to be unique, and pivot enforces that and raises ReshapeError if it is not, so no separate check is needed here.
- Parameters:
- longNativeDataFrame
A long-format frame, e.g. from FCACallReport.to_long_format.
- dataframe_type{“pandas”, “pyarrow_table”, “polars_lazyframe”, “polars_dataframe”}, optional
The dataframe type to convert the result to as a final step. Leave this
None(the default) to get back whatever backend call_report.config.get_config currently has configured.
- Returns:
- NativeDataFrame
The wide-format frame (see FCACallReport.to_wide_format), of the configured backend, or of dataframe_type if it was supplied.
- Raises:
- ReshapeError
If (UNINUM, period, schedule, code_column, code_value, variable_name) is not a unique grain.
Examples
>>> from call_report.fca.transport import PackagedArchiveTransport >>> from call_report.fca.report import FCACallReport >>> report = FCACallReport( ... start="2026-03-31", ... end="2026-03-31", ... transport=PackagedArchiveTransport(), ... ) >>> long = report.to_long_format(schedules=["RC", "RCB"]) >>> wide = convert_long_format_to_wide_format(long=long) >>> "RCB__INV_CODE_15__BKVAL" in wide.columns True