mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-24 10:34:18 -08:00
* Adds flake8, pylint, liccheck, flake8 to dependencies for data-pipeline * Sets up and runs black autoformatting * Adds flake8 to tox linting * Fixes flake8 error F541 f string missing placeholders * Fixes flake8 E501 line too long * Fixes flake8 F401 imported but not used * Adds pylint to tox and disables the following pylint errors: - C0114: module docstrings - R0201: method could have been a function - R0903: too few public methods - C0103: name case styling - W0511: fix me - W1203: f-string interpolation in logging * Adds utils.py to tox.ini linting, runs black on utils.py * Fixes import related pylint errors: C0411 and C0412 * Fixes or ignores remaining pylint errors (for discussion later) * Adds safety and liccheck to tox.ini
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import pandas as pd
|
|
|
|
from etl.base import ExtractTransformLoad
|
|
from utils import get_module_logger
|
|
|
|
logger = get_module_logger(__name__)
|
|
|
|
|
|
class EJScreenETL(ExtractTransformLoad):
|
|
def __init__(self):
|
|
self.EJSCREEN_FTP_URL = (
|
|
"https://gaftp.epa.gov/EJSCREEN/2019/EJSCREEN_2019_StatePctile.csv.zip"
|
|
)
|
|
self.EJSCREEN_CSV = self.TMP_PATH / "EJSCREEN_2019_StatePctiles.csv"
|
|
self.CSV_PATH = self.DATA_PATH / "dataset" / "ejscreen_2019"
|
|
self.df: pd.DataFrame
|
|
|
|
def extract(self) -> None:
|
|
logger.info("Downloading EJScreen Data")
|
|
super().extract(
|
|
self.EJSCREEN_FTP_URL,
|
|
self.TMP_PATH,
|
|
)
|
|
|
|
def transform(self) -> None:
|
|
logger.info("Transforming EJScreen Data")
|
|
self.df = pd.read_csv(
|
|
self.EJSCREEN_CSV,
|
|
dtype={"ID": "string"},
|
|
# EJSCREEN writes the word "None" for NA data.
|
|
na_values=["None"],
|
|
low_memory=False,
|
|
)
|
|
|
|
def load(self) -> None:
|
|
logger.info("Saving EJScreen CSV")
|
|
# write nationwide csv
|
|
self.CSV_PATH.mkdir(parents=True, exist_ok=True)
|
|
self.df.to_csv(self.CSV_PATH / "usa.csv", index=False)
|