mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-07-28 23:11:16 -07:00
Analysis by region (#385)
* Adding regional comparisons * Small ETL fixes
This commit is contained in:
parent
81290ce672
commit
67b39475f7
7 changed files with 440 additions and 158 deletions
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path
|
||||
import csv
|
||||
import pandas as pd
|
||||
import os
|
||||
from config import settings
|
||||
|
||||
|
@ -53,3 +54,18 @@ def get_state_fips_codes(data_path: Path) -> list:
|
|||
fips = row[0].strip()
|
||||
fips_state_list.append(fips)
|
||||
return fips_state_list
|
||||
|
||||
|
||||
def get_state_information(data_path: Path) -> pd.DataFrame:
|
||||
"""Load the full state file as a dataframe.
|
||||
|
||||
Useful because of the state regional information.
|
||||
"""
|
||||
fips_csv_path = data_path / "census" / "csv" / "fips_states_2010.csv"
|
||||
|
||||
df = pd.read_csv(fips_csv_path)
|
||||
|
||||
# Left pad the FIPS codes with 0s
|
||||
df["fips"] = df["fips"].astype(str).apply(lambda x: x.zfill(2))
|
||||
|
||||
return df
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue