fbd16b4f301f09b8868b60a4762700f3251e2cdc,src/pudl/transform/ferc1.py,,plant_in_service,#Any#Any#,977

Before Change



    
    ferc1_row_maps_pkg = "pudl.package_data.meta.ferc1_row_maps"
    pis_row_map = pd.read_csv(
        importlib.resources.open_text(
            ferc1_row_maps_pkg, "f1_plant_in_srvce_map.csv"),
        index_col=0, comment="//"
    )

    // These are the "columns" in the FERC Form 1 that are reported by "row"
    // (corresponding to the FERC Accounts)
    pis_data_cols = [
        "begin_yr_bal",
        "addition",
        "retirements",
        "adjustments",
        "transfers",
        "yr_end_bal",
    ]

    pis_df = ferc1_raw_dfs["plant_in_service_ferc1"].copy()
    pis_df = unpack_rows(pis_df, pis_row_map, pis_data_cols)

    // Chunk out the now extremely wide table into categorized records
    // organized by the previously reported columns:
    categorized_pis = pd.DataFrame()
    for category in pis_df.columns.levels[0]:
        tmp_df = pis_df.loc[:, category].copy()
        tmp_df["amount_type"] = category
        categorized_pis = pd.concat([categorized_pis, tmp_df])
    categorized_pis.columns.name = None
    pis_df = (
        categorized_pis.reset_index()
        .assign(

After Change


        dict: The dictionary of the transformed DataFrames.

    
    pis_df = (
        unpack_table(
            ferc1_df=ferc1_raw_dfs["plant_in_service_ferc1"],
            table_name="f1_plant_in_srvce",
            data_rows=slice(None),  // Gotta catch "em all!
            data_cols=[
                "begin_yr_bal",
                "addition",
                "retirements",
                "adjustments",
                "transfers",
                "yr_end_bal"
            ])
        .pipe(  // Convert top level of column index into a categorical column:
            cols_to_cats,
            cat_name="amount_type",
            col_cats={
                "begin_yr_bal": "starting_balance",
                "addition": "additions",
                "retirements": "retirements",
                "adjustments": "adjustments",
                "transfers": "transfers",
                "yr_end_bal": "ending_balance",
            })
        .rename_axis(columns=None)
        .pipe(_clean_cols, "f1_plant_in_srvce")
        .set_index([
            "utility_id_ferc1",
            "report_year",
            "amount_type",
            "record_id"])
        .reset_index()
    )

    // Get rid of the columns corresponding to "header" rows in the FERC
    // form, which should *never* contain data... but in about 2 dozen cases,
    // they do. See this issue on Github for more information:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: catalyst-cooperative/pudl
Commit Name: fbd16b4f301f09b8868b60a4762700f3251e2cdc
Time: 2019-12-05
Author: zane.selvans@catalyst.coop
File Name: src/pudl/transform/ferc1.py
Class Name:
Method Name: plant_in_service


Project Name: geomstats/geomstats
Commit Name: b7efa1f037f8adc94a28fc421dd7934b63b3043e
Time: 2020-04-22
Author: 62605255+pchauchat@users.noreply.github.com
File Name: geomstats/_backend/numpy/__init__.py
Class Name:
Method Name: assignment


Project Name: dask/dask-image
Commit Name: cbbcea8795e8da754a5b3ffb1a08ef66afd84eef
Time: 2018-09-02
Author: jakirkham@gmail.com
File Name: dask_image/ndmeasure/_utils.py
Class Name:
Method Name: _ravel_shape_indices