Skip to content

Commit

Permalink
fix line length to hard 88
Browse files Browse the repository at this point in the history
  • Loading branch information
Austen Sharpe committed Mar 19, 2021
1 parent 5888f5b commit f7377a5
Show file tree
Hide file tree
Showing 6 changed files with 552 additions and 271 deletions.
115 changes: 72 additions & 43 deletions src/pudl/transform/eia860.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ def ownership(eia860_dfs, eia860_transformed_dfs):
Transformations include:
- Replace . values with NA.
- Convert pre-2012 ownership percentages to proportions to match post-2012 reporting.
* Replace . values with NA.
* Convert pre-2012 ownership percentages to proportions to match post-2012
reporting.
Args:
eia860_dfs (dict): Each entry in this dictionary of DataFrame objects
corresponds to a page from the EIA860 form, as reported in the Excel spreadsheets they distribute
eia860_transformed_dfs (dict): A dictionary of DataFrame objects in
which pages from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
corresponds to a page from the EIA860 form, as reported in the Excel
spreadsheets they distribute.
eia860_transformed_dfs (dict): A dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from
that page (values).
Returns:
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which
pages from EIA860 form (keys) correspond to normalized DataFrames of values
from that page (values).
"""
# Preiminary clean and get rid of unecessary 'year' column
Expand Down Expand Up @@ -72,29 +77,37 @@ def generators(eia860_dfs, eia860_transformed_dfs):
"""
Pull and transform the generators table.
There are three tabs that the generator records come from (proposed, existing, retired). Pre 2009, the existing and retired data are lumped together under a single generator file with one tab. We pull each tab into one dataframe and include an ``operational_status`` to indicate which tab the record came from. We use ``operational_status`` to parse the pre 2009 files as well.
There are three tabs that the generator records come from (proposed, existing,
retired). Pre 2009, the existing and retired data are lumped together under a single
generator file with one tab. We pull each tab into one dataframe and include an
``operational_status`` to indicate which tab the record came from. We use
``operational_status`` to parse the pre 2009 files as well.
Transformations include:
- Replace . values with NA.
- Update ``operational_status_code`` to reflect plant status as either
proposed, existing or retired.
- Drop values with NA for plant and generator id.
- Replace 0 values with NA where appropriate.
- Convert Y/N/X values to boolean True/False.
- Convert U/Unknown values to NA.
- Map full spelling onto code values.
- Create a fuel_type_code_pudl field that organizes fuel types into
* Replace . values with NA.
* Update ``operational_status_code`` to reflect plant status as either proposed,
existing or retired.
* Drop values with NA for plant and generator id.
* Replace 0 values with NA where appropriate.
* Convert Y/N/X values to boolean True/False.
* Convert U/Unknown values to NA.
* Map full spelling onto code values.
* Create a fuel_type_code_pudl field that organizes fuel types into
clean, distinguishable categories.
Args:
eia860_dfs (dict): Each entry in this
dictionary of DataFrame objects corresponds to a page from the EIA860 form, as reported in the Excel spreadsheets they distribute.
dictionary of DataFrame objects corresponds to a page from the EIA860 form,
as reported in the Excel spreadsheets they distribute.
eia860_transformed_dfs (dict): A dictionary of DataFrame objects in
which pages from EIA860 form (keys) correspond to a normalized DataFrame of values from that page (values)
which pages from EIA860 form (keys) correspond to a normalized DataFrame of
values from that page (values).
Returns:
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values).
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that
page (values).
"""
# Groupby objects were creating chained assignment warning that is N/A
Expand Down Expand Up @@ -252,22 +265,29 @@ def plants(eia860_dfs, eia860_transformed_dfs):
"""
Pull and transform the plants table.
Much of the static plant information is reported repeatedly, and scattered across several different pages of EIA 923. The data frame which this function uses is assembled from those many different pages, and passed in via the same dictionary of dataframes that all the other ingest functions use for uniformity.
Much of the static plant information is reported repeatedly, and scattered across
several different pages of EIA 923. The data frame which this function uses is
assembled from those many different pages, and passed in via the same dictionary of
dataframes that all the other ingest functions use for uniformity.
Transformations include:
- Replace . values with NA.
- Homogenize spelling of county names.
- Convert Y/N/X values to boolean True/False.
* Replace . values with NA.
* Homogenize spelling of county names.
* Convert Y/N/X values to boolean True/False.
Args:
eia860_dfs (dict): Each entry in this dictionary of DataFrame objects
corresponds to a page from the EIA860 form, as reported in the Excel spreadsheets they distribute.
corresponds to a page from the EIA860 form, as reported in the Excel
spreadsheets they distribute.
eia860_transformed_dfs (dict): A dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
from EIA860 form (keys) correspond to normalized DataFrames of values from
that page (values).
Returns:
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that
page (values).
"""
# Populating the 'plants_eia860' table
Expand Down Expand Up @@ -336,17 +356,21 @@ def boiler_generator_assn(eia860_dfs, eia860_transformed_dfs):
Transformations include:
- Drop non-data rows with EIA notes.
- Drop duplicate rows.
* Drop non-data rows with EIA notes.
* Drop duplicate rows.
Args:
eia860_dfs (dict): Each entry in this dictionary of DataFrame objects
corresponds to a page from the EIA860 form, as reported in the Excel spreadsheets they distribute.
corresponds to a page from the EIA860 form, as reported in the Excel
spreadsheets they distribute.
eia860_transformed_dfs (dict): A dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
from EIA860 form (keys) correspond to normalized DataFrames of values from
that page (values).
Returns:
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that
page (values).
"""
# Populating the 'generators_eia860' table
Expand Down Expand Up @@ -388,22 +412,26 @@ def utilities(eia860_dfs, eia860_transformed_dfs):
Transformations include:
- Replace . values with NA.
- Fix typos in state abbreviations, convert to uppercase.
- Drop address_3 field (all NA).
- Combine phone number columns into one field and set values that don't
mimic real US phone numbers to NA.
- Convert Y/N/X values to boolean True/False.
- Map full spelling onto code values.
* Replace . values with NA.
* Fix typos in state abbreviations, convert to uppercase.
* Drop address_3 field (all NA).
* Combine phone number columns into one field and set values that don't mimic real
US phone numbers to NA.
* Convert Y/N/X values to boolean True/False.
* Map full spelling onto code values.
Args:
eia860_dfs (dict): Each entry in this
dictionary of DataFrame objects corresponds to a page from the EIA860 form, as reported in the Excel spreadsheets they distribute.
dictionary of DataFrame objects corresponds to a page from the EIA860 form,
as reported in the Excel spreadsheets they distribute.
eia860_transformed_dfs (dict): A dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
from EIA860 form (keys) correspond to normalized DataFrames of values from
that page (values).
Returns:
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages from EIA860 form (keys) correspond to normalized DataFrames of values from that page (values)
dict: eia860_transformed_dfs, a dictionary of DataFrame objects in which pages
from EIA860 form (keys) correspond to normalized DataFrames of values from that
page (values).
"""
# Populating the 'utilities_eia860' table
Expand Down Expand Up @@ -485,10 +513,11 @@ def transform(eia860_raw_dfs, eia860_tables=pc.pudl_tables["eia860"]):
eia860_raw_dfs (dict): a dictionary of tab names (keys) and DataFrames
(values). This can be generated by pudl.
eia860_tables (tuple): A tuple containing the names of the EIA 860 tables that
can be pulled into PUDL
can be pulled into PUDL.
Returns:
dict: A dictionary of DataFrame objects in which pages from EIA860 form (keys) corresponds to a normalized DataFrame of values from that page (values)
dict: A dictionary of DataFrame objects in which pages from EIA860 form (keys)
corresponds to a normalized DataFrame of values from that page (values).
"""
# these are the tables that we have transform functions for...
Expand Down
Loading

0 comments on commit f7377a5

Please sign in to comment.