pudl.transform.rus#
Code for transforming RUS data that pertains to more than one RUS Form.
Attributes#
Classes#
Enum for the different types of RUS entities. |
Functions#
|
Check the expected primary key of the table. |
|
Standard transforms for raw RUS data. |
|
Convert units within a column and rename column with new units. |
|
An asset factory for finished RUS tables. |
Module Contents#
- pudl.transform.rus.early_check_pk(df: pandas.DataFrame, pk_early: list[str] = ['report_date', 'borrower_id_rus'], raise_fail=True) None[source]#
Check the expected primary key of the table.
By default the expected primary key is [“report_date”, “borrower_id_rus”].
- pudl.transform.rus.early_transform(raw_df: pandas.DataFrame, boolean_columns_to_fix=[], string_cols_to_simplify=[]) pandas.DataFrame[source]#
Standard transforms for raw RUS data.
- pudl.transform.rus.convert_units(df: pandas.DataFrame, old_unit: str, new_unit: str | None, converter: float | int) pandas.DataFrame[source]#
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_kwhorpurchased_kwh, the old unit would bekwh, the new unit would bemwhand the converter would be0.001.- Parameters:
df – data table with units you’d like to convert.
old_unit – the unit in the df. This must be the suffix of the column names you’d like to convert.
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 ()””).
converter – the float or integer you need to multiply the old values by to convert the units.
- class pudl.transform.rus.RusEntity[source]#
Bases:
enum.StrEnumEnum for the different types of RUS entities.
- pudl.transform.rus.finished_rus_asset_factory(table_name: str, _core_table_name: str, io_manager_key: str | None = None) dagster.AssetsDefinition[source]#
An asset factory for finished RUS tables.
- Parameters:
table_name – the name of the core table.
_core_table_name – the name of the unharvested input table
io_manager_key – the name of the IO Manager of the final asset.
- Returns:
A RUS asset.