pudl.transform.rus ================== .. py:module:: pudl.transform.rus .. autoapi-nested-parse:: Code for transforming RUS data that pertains to more than one RUS Form. Attributes ---------- .. autoapisummary:: pudl.transform.rus.logger Classes ------- .. autoapisummary:: pudl.transform.rus.RusEntity Functions --------- .. autoapisummary:: pudl.transform.rus.early_check_pk pudl.transform.rus.early_transform pudl.transform.rus.convert_units pudl.transform.rus.finished_rus_asset_factory Module Contents --------------- .. py:data:: logger .. py:function:: early_check_pk(df: pandas.DataFrame, pk_early: list[str] = ['report_date', 'borrower_id_rus'], raise_fail=True) -> None Check the expected primary key of the table. By default the expected primary key is ["report_date", "borrower_id_rus"]. .. py:function:: early_transform(raw_df: pandas.DataFrame, boolean_columns_to_fix=[], string_cols_to_simplify=[]) -> pandas.DataFrame Standard transforms for raw RUS data. .. py:function:: convert_units(df: pandas.DataFrame, old_unit: str, new_unit: str | None, converter: float | int) -> pandas.DataFrame Convert units within a column and rename column with new units. This function assumes that the old units are suffixes in the snake-cased column names, separated by an underscore. Ex: if you want to convert from kWh's to MWh's the df must have column names like ``electric_sales_kwh`` or ``purchased_kwh``, the old unit would be ``kwh``, the new unit would be ``mwh`` and the converter would be ``0.001``. :param df: data table with units you'd like to convert. :param old_unit: the unit in the df. This must be the suffix of the column names you'd like to convert. :param new_unit: the new unit label you want as the new suffix of the resulting dataframe. If you want no new unit added, this value can be None or an empty string ()""). :param converter: the float or integer you need to multiply the old values by to convert the units. .. py:class:: RusEntity Bases: :py:obj:`enum.StrEnum` Enum for the different types of RUS entities. .. py:attribute:: BORROWERS .. py:function:: finished_rus_asset_factory(table_name: str, _core_table_name: str, io_manager_key: str | None = None) -> dagster.AssetsDefinition An asset factory for finished RUS tables. :param table_name: the name of the core table. :param _core_table_name: the name of the unharvested input table :param io_manager_key: the name of the IO Manager of the final asset. :returns: A RUS asset.