primap2.pm2io.nir_convert_df_to_long

primap2.pm2io.nir_convert_df_to_long#

primap2.pm2io.nir_convert_df_to_long(df_nir: DataFrame, year: int, header_long: list[str] | None = None) DataFrame[source]#

Convert an entity-wide NIR table for a single year to a long format DataFrame.

The input DataFrame is required to have the following structure: * Columns for category, original category name, and data in this order, where category and original category name form a multiindex. * Column header as multiindex for entity and unit A column for the year is added during the conversion.

Parameters:
df_nir: pd.DataFrame

Pandas DataFrame with the NIR table to be converted

year: int

Year of the given data

header_long: list, optional

specify a non-standard column header, e.g. with only category code or orig_cat_name

Returns:
pd.DataFrame

converted DataFrame