Skip to content

Commit

Permalink
formatting only
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Nov 14, 2023
1 parent 90f4502 commit e20778a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions offsets_db_data/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,20 @@ def find_protocol(search_string: str, inverted_protocol_mapping: dict[str, list[

def get_protocol_category(protocol_strs: list[str] | str, protocol_mapping: dict) -> list[str]:
"""
Get category based on protocol string
Parameters
----------
protocol_strs : str or list
normalized protocol strings
protocol_mapping dict
metadata about normalized protocols
single protocol string or list of protocol strings
protocol_mapping: dict
metadata about normalized protocol strings
Returns
-------
list[str] :
list of category strings
categories : list[str]
list of category strings
"""

def _get_category(protocol_str, protocol_mapping):
Expand All @@ -353,14 +356,26 @@ def _get_category(protocol_str, protocol_mapping):
if isinstance(protocol_strs, str):
protocol_strs = [protocol_strs]
categories = [_get_category(protocol_str, protocol_mapping) for protocol_str in protocol_strs]
return list(set(categories)) # if multiple protocols have same category, just return category once
return list(
set(categories)
) # if multiple protocols have same category, just return category once


def harmonize_acr_status(row: pd.Series) -> str:
"""Derive single project status for CAR and ACR projects
Raw CAR and ACR data has two status columns -- one for compliance status, one for voluntary.
Handle and harmonize.
Parameters
----------
row : pd.Series
A row from a pandas DataFrame
Returns
-------
value : str
The status of the project
"""
if row['Compliance Program Status (ARB or Ecology)'] == 'Not ARB or Ecology Eligible':
return row['Voluntary Status'].lower()
Expand Down

0 comments on commit e20778a

Please sign in to comment.